mspack_rb 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
  SHA1:
3
- metadata.gz: 7344a42572aaac8736edceaa4b344f7ae61125bf
4
- data.tar.gz: 05fcde6d525e3e7814212b00cd7987dcd8d7e94d
3
+ metadata.gz: e3331241485b768fdacd9594f34633dab368f983
4
+ data.tar.gz: a6220df39ae20ae2930c28513f96d3f570363db8
5
5
  SHA512:
6
- metadata.gz: e43ac5361052d84ec4d166c202022dfd4938c95595856e1b8215ca3e29dd69541e3e266e6bcd58db7c4e0a908cd29a84bc523d633c3396fa496fb126fea49aa2
7
- data.tar.gz: c47aa65dc8dba1e5a632090d1f1c9e6a9358bca907ea36899df79b594380ae5c72315ca8ff7152decdaf3989777a88b0f0fa95511df70f639af660d76d9a8743
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, out_path) }
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
- path = Mspack.ensure_path(file.filename, dir)
11
- extract_to_path(file, path)
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
 
@@ -1,3 +1,3 @@
1
1
  module Mspack
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mspack_rb
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
  - Ben Williams