partoo 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: 8b81246eb7b48a99da7050cb30080b40226670f8
4
- data.tar.gz: 20ec46d107e331ccd25ba8a27d735af7e7027d87
3
+ metadata.gz: c31afedd9393225ff157f75075328594991c7bb3
4
+ data.tar.gz: 448a0eb5b0b3accbe7e4fb7bc123c1bd7496a439
5
5
  SHA512:
6
- metadata.gz: d67efda133a325960372ed02188f6f6f837104aad02eccde4baeb6cd0d2863e3907e89196cb1f66fb6fe05208c28ce11247b9a7980d217f21d377d66d52e0156
7
- data.tar.gz: 0fa54c15a945f7b1983b4c1c6f0b462db5b30f68afe030dff57516c81e5aeca9231f27788a54f35440834df9853ae31e96d368f0cebce91451ba6f4bb2543855
6
+ metadata.gz: 2e3d1debd91dbd5b4be1d8d406a9d88d4c2005897df23318434b1605f23af2cbb61a3d8bd6e82b671be535c4dffe2446be790e3c354bc05e6f213326279a7089
7
+ data.tar.gz: 03d58683a7de71e270ad30b632dcab5b0de5302076b21259f623c7a2d5608f3067479da6d4fe7c8ae61f79aec9c4bc8eba5851127fdf0072e5875db76e7885aa
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Version ](https://img.shields.io/gem/v/partoo.svg?style=flat)](https://rubygems.org/gems/partoo)
2
+
1
3
  # Partoo
2
4
 
3
5
  Do cool things with par2 files.
@@ -26,6 +28,8 @@ Commands:
26
28
  partoo help [COMMAND] # Describe available commands or one specific command
27
29
  partoo inspect <attribute> <par2 file> # Inspect a particular attribute of a par2 file
28
30
  partoo list <par2 file> # Lists files described in a par2 file
31
+ partoo tomd5 <par2 file> # Build an md5 file from par2 file data
32
+ partoo tosfv <par2 file> # Build an sfv file from par2 file data
29
33
  ```
30
34
 
31
35
  ## Development
@@ -42,5 +42,17 @@ module Partoo
42
42
  f = Par2File.read(io)
43
43
  f.slice_size
44
44
  end
45
+
46
+ def to_md5(par2_file)
47
+ io = File.open(par2_file)
48
+ f = Par2File.read(io)
49
+ f.to_md5
50
+ end
51
+
52
+ def to_sfv(par2_file)
53
+ io = File.open(par2_file)
54
+ f = Par2File.read(io)
55
+ f.to_sfv
56
+ end
45
57
  end
46
58
  end
@@ -12,7 +12,7 @@ module Partoo
12
12
 
13
13
  desc "inspect <attribute> <par2 file>", "Inspect a particular attribute of a par2 file"
14
14
  long_desc <<-LONGDESC
15
- Inspect a particular attribute of a par2 file"
15
+ Inspect a particular attribute of a par2 file
16
16
 
17
17
  Attributes:
18
18
  creator
@@ -38,5 +38,14 @@ module Partoo
38
38
  end
39
39
  end
40
40
 
41
+ desc "tomd5 <par2 file>", "Build an md5 file from par2 file data"
42
+ def tomd5(par2_file)
43
+ puts Partoo.to_md5(par2_file)
44
+ end
45
+
46
+ desc "tosfv <par2 file>", "Build an sfv file from par2 file data"
47
+ def tosfv(par2_file)
48
+ puts Partoo.to_sfv(par2_file)
49
+ end
41
50
  end
42
51
  end
@@ -15,6 +15,26 @@ module Partoo
15
15
  end
16
16
  end
17
17
 
18
+ def to_md5
19
+ file_ids.sort_by do |id|
20
+ file_description_packet_by_id(id)[0]['body']['file_name']
21
+ end.map do |id|
22
+ file_description_packet_by_id(id)[0]['body']['file_md5'].to_hex
23
+ .concat(' ')
24
+ .concat(file_description_packet_by_id(id)[0]['body']['file_name'])
25
+ end.join("\n").concat("\n")
26
+ end
27
+
28
+ def to_sfv
29
+ file_ids.sort_by do |id|
30
+ file_description_packet_by_id(id)[0]['body']['file_name']
31
+ end.map do |id|
32
+ file_description_packet_by_id(id)[0]['body']['file_name']
33
+ .concat(' ')
34
+ .concat(crc32_by_id(id).to_s(16).rjust(8, '0'))
35
+ end.join("\n").concat("\n")
36
+ end
37
+
18
38
  def crc32_by_id(id)
19
39
  crc = ""
20
40
  input_file_slice_checksum_packet_by_id(id)[0]['body']['chunk_checksums'].each do |cc|
@@ -1,3 +1,3 @@
1
1
  module Partoo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: partoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - matt.cover
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-01 00:00:00.000000000 Z
11
+ date: 2017-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata