mspack_rb 0.2.0 → 0.2.1
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/README.md +5 -2
- data/lib/mspack/chm_decompressor.rb +8 -3
- data/lib/mspack/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3331241485b768fdacd9594f34633dab368f983
|
4
|
+
data.tar.gz: a6220df39ae20ae2930c28513f96d3f570363db8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c4d6334ea6e2a9b7c6b2585fd833bb057a48ac5c871b58ad7c82490f082858c4732aa36a4fd678f1ae7e7b4623ff311b68395298b6dd7653076b0b88504a563
|
7
|
+
data.tar.gz: 5eef83cb7a97ff4bc3e5fc15dd2c061e28ebfa9516d940adbf9c2c2508f25946349ffd5b72235180f263fb409533d94025c600e339a81d71fe32cb573d161e00
|
data/README.md
CHANGED
@@ -13,13 +13,16 @@ The gem is available over at [https://rubygems.org/gems/mspack_rb](https://rubyg
|
|
13
13
|
# Extract all files to disk
|
14
14
|
dcom = Mspack::ChmDecompressor.new
|
15
15
|
header = dcom.open('path/to/a/chm/file')
|
16
|
-
header.each_file { |file| dcom.extract(file,
|
16
|
+
header.each_file { |file| dcom.extract(file, '/some/folder') }
|
17
17
|
dcom.close(header)
|
18
18
|
|
19
19
|
# Extract a specific file by name
|
20
20
|
fast_open_header = dcom.fast_open('path/to/a/chm/file')
|
21
21
|
file = dcom.fast_find(fast_open_header, '/index.html')
|
22
|
-
dcom.extract(file) unless file.nil?
|
22
|
+
dcom.extract(file, '~/some/folder') unless file.nil?
|
23
|
+
|
24
|
+
# Get extracted file bytes as an array
|
25
|
+
dcom.extract(file) { |data_chunk| do_something_with_array(data_chunk) }
|
23
26
|
|
24
27
|
# check last error
|
25
28
|
p 'w00t' if dcom.last_error == :ok
|
@@ -6,9 +6,14 @@ module Mspack
|
|
6
6
|
# Expects a ChmDecompressor::File and a string.
|
7
7
|
# Calls Mspack.ensure_path and extracts file.
|
8
8
|
# Returns the absolute file path.
|
9
|
-
def extract(file, dir)
|
10
|
-
|
11
|
-
|
9
|
+
def extract(file, dir = nil)
|
10
|
+
if block_given?
|
11
|
+
extract_to_path(file) { |data| yield data }
|
12
|
+
else
|
13
|
+
path = Mspack.ensure_path(file.filename, dir)
|
14
|
+
extract_to_path(file, path)
|
15
|
+
end
|
16
|
+
|
12
17
|
path
|
13
18
|
end
|
14
19
|
|
data/lib/mspack/version.rb
CHANGED