poise-archive 1.1.1 → 1.1.2

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: 91ccb73c49f6703d1836d4ea834300556e636022
4
- data.tar.gz: 98c56241ab537943ca0a6e4b5e0c7490a0fb5fdf
3
+ metadata.gz: cfaafe9923ce43911a655e20b02ab6dd00cb7048
4
+ data.tar.gz: 80cc2672a626c92f4448b5936d5d10a51420c73c
5
5
  SHA512:
6
- metadata.gz: e3a403715a2874abda4d9382226b234dcacafb93799cdf5ff69b2b4a6c0e788134301fd9c4c51370462cc64a6441d4cfe91bdcbebdf7ba3844b72202ad47ebb7
7
- data.tar.gz: 1cf28ee3de172108eebaf3e9f408c8245e846d8f2c98dac4da3c26894d24d1f5e6dc69c50bef2404871360783322635e5ba55a2e5051bfaee045d5efa83c3ba6
6
+ metadata.gz: 6f46fc0af69806f98c569071ffd083f377614eae6ef598be79691957b709506cda3e5f719523f27cc00b164c0b3d9cbf611e147ac76aaacf8fb633c07f1f9f3b
7
+ data.tar.gz: b482be77a33a595e75f4a9d6ce56126cee7c7e452132c0a3e127bf8ed8834439abe2e00970878a6cb7ed31e702b303f384e68089aade9f6b286370ae78c07100
@@ -1,5 +1,9 @@
1
1
  # Poise-Archive Changelog
2
2
 
3
+ ## v1.1.2
4
+
5
+ * Fix compat with older Ruby that doesn't include `Entry#symlink?`.
6
+
3
7
  ## v1.1.1
4
8
 
5
9
  * Fix GNU tar longlink extension.
@@ -47,23 +47,11 @@ module PoiseArchive
47
47
  #
48
48
  # @return [void]
49
49
  def unpack_tar
50
- entry_name = nil
51
- tar_each do |entry|
52
- if entry.full_name == TAR_LONGLINK
53
- # Stash the longlink name so it will be used for the next entry.
54
- entry_name = entry.read.strip
55
- # And then skip forward because this isn't a real block.
56
- next
57
- end
58
- # For entries not preceded by a longlink block, use the normal name.
59
- entry_name ||= entry.full_name
60
- # Process strip_components by mangling the name.
61
- parsed_name = entry_name.split(/\//).drop(new_resource.strip_components).join('/')
62
- # Reset entry_name for the next entry.
63
- entry_name = nil
50
+ tar_each_with_longlink do |entry|
51
+ entry_name = entry.full_name.split(/\//).drop(new_resource.strip_components).join('/')
64
52
  # If strip_components wiped out the name, don't process this entry.
65
- next if parsed_name.empty?
66
- dest = ::File.join(new_resource.destination, parsed_name)
53
+ next if entry_name.empty?
54
+ dest = ::File.join(new_resource.destination, entry_name)
67
55
  if entry.directory?
68
56
  Dir.mkdir(dest, entry.header.mode)
69
57
  elsif entry.file?
@@ -72,7 +60,7 @@ module PoiseArchive
72
60
  dest_f.write(buf)
73
61
  end
74
62
  end
75
- elsif entry.symlink?
63
+ elsif entry.header.typeflag == '2' # symlink? is new in Ruby 2.0, apparently.
76
64
  ::File.symlink(entry.header.linkname, dest)
77
65
  else
78
66
  raise RuntimeError.new("Unknown tar entry type #{entry.header.typeflag.inspect} in #{new_resource.path}")
@@ -81,6 +69,25 @@ module PoiseArchive
81
69
  end
82
70
  end
83
71
 
72
+ def tar_each_with_longlink(&block)
73
+ entry_name = nil
74
+ tar_each do |entry|
75
+ if entry.full_name == TAR_LONGLINK
76
+ # Stash the longlink name so it will be used for the next entry.
77
+ entry_name = entry.read.strip
78
+ # And then skip forward because this isn't a real block.
79
+ next
80
+ end
81
+ # For entries not preceded by a longlink block, use the normal name.
82
+ entry_name ||= entry.full_name
83
+ # Make the entry return the correct name.
84
+ entry.define_singleton_method(:full_name) { entry_name }
85
+ block.call(entry)
86
+ # Reset entry_name for the next entry.
87
+ entry_name = nil
88
+ end
89
+ end
90
+
84
91
  # Sequence the opening, iteration, and closing.
85
92
  #
86
93
  # @param block [Proc] Block to process each tar entry.
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module PoiseArchive
19
- VERSION = '1.1.1'
19
+ VERSION = '1.1.2'
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poise-archive
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-01 00:00:00.000000000 Z
11
+ date: 2016-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: halite