excavate 0.3.2 → 0.3.4

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: fa5e513f27e2996c18e3b006569540ec1c06c8b178460e2241a891e42fddcfda
4
- data.tar.gz: 3a0c7b6f1829f2a1d2ff4645d8b40d677a54b693351a883b53b2feb47d29b9b3
3
+ metadata.gz: 7a8ee881421934ef0e3333fe045b1af9d8925b93930fe2f7fd136254ff308382
4
+ data.tar.gz: 9ca82179fdc265ba891c262f95d200c73bf2376399abd106135a6dcc8e2479e5
5
5
  SHA512:
6
- metadata.gz: 7176e3bb221ef27aa16bb666f278d2081030c28778380fa40b5cdd44737fef9b5a76e9f7b7475dfaceaf33583b7caea80590f39e3a2a5f614f9a957baf082af8
7
- data.tar.gz: '0359c8ea5ac50e2ad79c8c453b81a5dea7c2a11c1c1e9accf0844aa5f6ea110a3cfe692819c8c786c45a1191cce2d26259135832238fb268a31e913696cac951'
6
+ metadata.gz: 85d30df5e364ea3207a28a10cdf28dbe7020bf03af32661a43d925aaf29b2413995dd7eab0184e881e06b3910098d11018e1bc22f718e82e75c277d01459e28b
7
+ data.tar.gz: bfea734b56d0e83574d97ce009555cac2130ee13c1a35e83c331579718d5619ae956adba4479c0d2748d416083be269b6e88092bb39d47ed733aa3bbadbd3c81
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
+ /.vscode
3
4
  /_yardoc/
4
5
  /coverage/
5
6
  /doc/
data/excavate.gemspec CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  require_relative "lib/excavate/version"
4
4
 
5
+ # rubocop:disable Metrics/BlockLength
6
+
5
7
  Gem::Specification.new do |spec|
6
8
  spec.name = "excavate"
7
9
  spec.version = Excavate::VERSION
@@ -35,11 +37,13 @@ Gem::Specification.new do |spec|
35
37
  spec.add_runtime_dependency "libmspack", "~> 0.1"
36
38
  spec.add_runtime_dependency "ruby-ole", "~> 1.0"
37
39
  spec.add_runtime_dependency "rubyzip", "~> 2.3"
40
+ spec.add_runtime_dependency "seven-zip", "~> 1.4"
38
41
  spec.add_runtime_dependency "thor", "~> 1.0"
39
42
 
40
43
  spec.add_development_dependency "rspec", "~> 3.0"
41
44
  spec.add_development_dependency "rubocop", "~> 1.7"
42
45
  spec.add_development_dependency "rubocop-performance", "~> 1.15"
43
-
44
46
  spec.metadata["rubygems_mfa_required"] = "false"
45
47
  end
48
+
49
+ # rubocop:enable Metrics/BlockLength
@@ -184,6 +184,12 @@ module Excavate
184
184
  FileUtils.cp(archive, target)
185
185
  end
186
186
 
187
+ def may_be_nested_cab?(extension, message)
188
+ extension == "exe" &&
189
+ message.start_with?("Invalid file format",
190
+ "Unrecognized archive format")
191
+ end
192
+
187
193
  def extract_once(archive, target)
188
194
  extension = normalized_extension(archive)
189
195
  extractor_class = TYPES[extension]
@@ -193,8 +199,7 @@ module Excavate
193
199
 
194
200
  extractor_class.new(archive).extract(target)
195
201
  rescue StandardError => e
196
- raise unless extension == "exe" &&
197
- e.message.start_with?("Invalid file format")
202
+ raise unless may_be_nested_cab?(extension, e.message)
198
203
 
199
204
  Extractors::CabExtractor.new(archive).extract(target)
200
205
  end
@@ -235,6 +240,8 @@ module Excavate
235
240
  return false unless File.file?(file)
236
241
 
237
242
  ext = normalized_extension(file)
243
+ return false if ext == "gz" && FileMagic.detect(file) != :gzip
244
+
238
245
  TYPES.key?(ext)
239
246
  end
240
247
  end
@@ -1,24 +1,15 @@
1
- require "ffi-libarchive-binary"
1
+ require "seven_zip_ruby"
2
2
 
3
3
  module Excavate
4
4
  module Extractors
5
5
  class SevenZipExtractor < Extractor
6
6
  def extract(target)
7
7
  Dir.chdir(target) do
8
- extract_with_libarchive
8
+ File.open(@archive, "rb") do |file|
9
+ SevenZipRuby::Reader.extract_all(file, target)
10
+ end
9
11
  end
10
12
  end
11
-
12
- def extract_with_libarchive
13
- flags = ::Archive::EXTRACT_PERM
14
- reader = ::Archive::Reader.open_filename(@archive)
15
-
16
- reader.each_entry do |entry|
17
- reader.extract(entry, flags.to_i)
18
- end
19
-
20
- reader.close
21
- end
22
13
  end
23
14
  end
24
15
  end
@@ -9,9 +9,15 @@ module Excavate
9
9
  end
10
10
 
11
11
  def detect
12
- case File.read(@path, 8, mode: "rb")
12
+ beginning = File.read(@path, 8, mode: "rb")
13
+ case beginning
13
14
  when "MSCF\x00\x00\x00\x00".force_encoding("BINARY")
14
15
  :cab
16
+ else
17
+ case beginning.byteslice(0, 2)
18
+ when "\x1F\x8B".force_encoding("BINARY")
19
+ :gzip
20
+ end
15
21
  end
16
22
  end
17
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Excavate
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excavate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-26 00:00:00.000000000 Z
11
+ date: 2023-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arr-pm
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '2.3'
103
+ - !ruby/object:Gem::Dependency
104
+ name: seven-zip
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.4'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '1.4'
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: thor
105
119
  requirement: !ruby/object:Gem::Requirement
@@ -201,7 +215,7 @@ metadata:
201
215
  source_code_uri: https://github.com/fontist/excavate
202
216
  changelog_uri: https://github.com/fontist/excavate
203
217
  rubygems_mfa_required: 'false'
204
- post_install_message:
218
+ post_install_message:
205
219
  rdoc_options: []
206
220
  require_paths:
207
221
  - lib
@@ -216,8 +230,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
230
  - !ruby/object:Gem::Version
217
231
  version: '0'
218
232
  requirements: []
219
- rubygems_version: 3.3.7
220
- signing_key:
233
+ rubygems_version: 3.4.10
234
+ signing_key:
221
235
  specification_version: 4
222
236
  summary: Extract nested archives with a single command.
223
237
  test_files: []