excavate 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: e470dda7c9344874bb4cf08f4a769817036ad080139a88047042d402e9d5acec
4
- data.tar.gz: 4428084b936ada2dd5ed5179007a73f150abe96763c7df117718d685d6384447
3
+ metadata.gz: fe53a363bd11b14249732d9c553b9efc00a4a9ab0ac156d90ea48afac366607e
4
+ data.tar.gz: af6bac0b0faace666c557fa4c66f32ef31a659110629916ac82a74172ad2c448
5
5
  SHA512:
6
- metadata.gz: f07491b7d61cd96023cf0ffd2054ce0484f4cba47165cd3bfc1e06c4c98678daa79dd50e54331d5c8c33435028e329751cc6a574d1d37e865caa6d468f66d043
7
- data.tar.gz: f2bd8e1666a1d86cad6e33ae7b6a6861c53c990552710b2f3b828a2cb056c127e92ed31efa46ca2ce96ce19c9eab68819d814373eba01fb8b7b2240b55d4a0ad
6
+ metadata.gz: 974a4e58890cc0d2b4a472d5a8d3a580ffb1a6bdc47f7e41c1e212692d636936921718be201c320069eefd7e6677b91266fafedbfcf393bfafbb714dede984cf
7
+ data.tar.gz: 0634316b5893c0a58bba0f1d0e756ccedbadd5061acd344b2c3d0c93810f5363a9cfe5cf4220454884a07c1a81f537b74e0abca2f86aa04d619bebb72021c686
@@ -21,6 +21,7 @@ module Excavate
21
21
  if entry.directory?
22
22
  FileUtils.mkdir_p(path)
23
23
  else
24
+ FileUtils.mkdir_p(File.dirname(path))
24
25
  File.write(path, file.read, mode: "wb")
25
26
  end
26
27
  end
@@ -34,6 +35,7 @@ module Excavate
34
35
  if entry.directory?
35
36
  FileUtils.mkdir_p(path)
36
37
  else
38
+ FileUtils.mkdir_p(File.dirname(path))
37
39
  File.write(path, entry.data, mode: "wb")
38
40
  end
39
41
  end
@@ -5,15 +5,29 @@ module Excavate
5
5
  class XarExtractor < Extractor
6
6
  def extract(target)
7
7
  Dir.chdir(target) do
8
- flags = ::Archive::EXTRACT_PERM
9
- reader = ::Archive::Reader.open_filename(@archive)
8
+ extract_with_libarchive
9
+ rename_payload(target)
10
+ end
11
+ end
10
12
 
11
- reader.each_entry do |entry|
12
- reader.extract(entry, flags.to_i)
13
- end
13
+ private
14
14
 
15
- reader.close
15
+ def extract_with_libarchive
16
+ flags = ::Archive::EXTRACT_PERM
17
+ reader = ::Archive::Reader.open_filename(@archive)
18
+
19
+ reader.each_entry do |entry|
20
+ reader.extract(entry, flags.to_i)
16
21
  end
22
+
23
+ reader.close
24
+ end
25
+
26
+ def rename_payload(target)
27
+ payload_path = File.join(target, "Payload")
28
+ return unless File.exist?(payload_path)
29
+
30
+ FileUtils.mv(payload_path, "#{payload_path}.cpio.gz")
17
31
  end
18
32
  end
19
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Excavate
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excavate
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
  - Ribose Inc.