archive-tar-external 1.4.2 → 1.5.0

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: 9b20d6fa4e2827a0326f31b43997f3191a1c35ac268d5de485689bb0b0ab59c0
4
- data.tar.gz: 4a4938677d58c08044547d5fb3bc7a71e669d1ffe11db0c1ba47cff35aecd70a
3
+ metadata.gz: 990b9b955f7f127b7e2cc3b74fc35116af8ea287fa24113a94c4027c76d859ba
4
+ data.tar.gz: 92b196efe6a52ddbc04dc5602cf0c1318cf5d1d0ac081e9701aa470046825e0b
5
5
  SHA512:
6
- metadata.gz: 703b000865ccddd8a1c54cbbebf47a4e2a6790964c1b9ef68663b5779dd286e8923b2dfe98d2b89a9161af457aadd588e1372a4ce9d49b7f7fa44110f094ec8e
7
- data.tar.gz: 0f72ea731fd952a4474eb553a789a4a78a8d79a41f6ad6c597a2328f948981251295dab4abb6bdabeac9770a85aa1fab6466f174c311e7c330fd3391bcb73aaa
6
+ metadata.gz: 804c66f9312a14ff9a413eecef0ad30adb77f0400c63667747c6a4e9a9a3ddaf99efc9381a5f72e44d34df89a2f95f6565605debfea1ea400f1e8976f1945f73
7
+ data.tar.gz: b2930a7e498792a701a81991475707642d228acab91a6faeb74ea1104c0a2bcbaf23625c9dd5c5ab7b0e56e2678e242e574b4e665b89cad586f8acb59a127ac2
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,4 +1,8 @@
1
- ## 1.4.2 - 1-May-2021
1
+ ## 1.5.0 - 1-May-2021
2
+ * A fourth option was added to the constructor. This allows you to set the
3
+ archive format. By default this is now set to 'pax'.
4
+
5
+ ## 1.4.2 - 30-Apr-2021
2
6
  * Switched from test-unit to rspec.
3
7
  * Added tighter versioning for the development dependencies.
4
8
  * Tests will now try to use gtar by default, if found.
data/README.md CHANGED
@@ -29,8 +29,11 @@ try to expand a file from an archive that does not contain that file.
29
29
 
30
30
  ### OSX
31
31
  It appears that the BSD tar that ships on Mac does not implement the -u
32
- option properly, and will add a file to the archive even if the timestamp
33
- of the file hasn't changed.
32
+ option properly by default, and will add a file to the archive even if
33
+ the timestamp of the file hasn't changed.
34
+
35
+ The OSX issue was effectively addressed in version 1.5.0, where the default
36
+ archive format was added and set to 'pax'.
34
37
 
35
38
  If you come across any other issues, please report them on the project
36
39
  page at https://github.com/djberg96/archive-tar-external.
@@ -3,7 +3,7 @@ require 'rbconfig'
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'archive-tar-external'
6
- spec.version = '1.4.2'
6
+ spec.version = '1.5.0'
7
7
  spec.summary = 'A simple way to create tar archives using external calls'
8
8
  spec.license = 'Apache-2.0'
9
9
  spec.author = 'Daniel Berger'
@@ -17,32 +17,40 @@ module Archive
17
17
  # This class encapsulates tar & zip operations.
18
18
  class Tar::External
19
19
  # The version of the archive-tar-external library.
20
- VERSION = '1.4.2'
20
+ VERSION = '1.5.0'
21
21
 
22
22
  # The name of the archive file to be used, e.g. "test.tar"
23
23
  attr_accessor :archive_name
24
24
 
25
- # The name of the tar program you wish to use. The default is "tar".
25
+ # The name of the tar program you wish to use. The default is "tar".
26
26
  attr_accessor :tar_program
27
27
 
28
28
  # The name of the archive file after compression, e.g. "test.tar.gz"
29
29
  attr_reader :compressed_archive_name
30
30
 
31
- # Returns an Archive::Tar::External object. The +archive_name+ is the
32
- # name of the tarball. While a .tar extension is recommended based on
31
+ # The format of the archive file. The default is "pax".
32
+ attr_reader :format
33
+
34
+ # Returns an Archive::Tar::External object. The +archive_name+ is the
35
+ # name of the tarball. While a .tar extension is recommended based on
33
36
  # years of convention, it is not enforced.
34
37
  #
35
38
  # Note that this does not actually create the archive unless you
36
- # pass a value to +file_pattern+. This then becomes a shortcut for
39
+ # pass a value to +file_pattern+. This then becomes a shortcut for
37
40
  # Archive::Tar::External.new + Archive::Tar::External#create_archive.
38
41
  #
39
42
  # If +program+ is provided, then it compresses the archive as well by
40
43
  # calling Archive::Tar::External#compress_archive internally.
41
44
  #
42
- def initialize(archive_name, file_pattern = nil, program = nil)
45
+ # You may also specify an archive format. As of version 1.5, the
46
+ # default is 'pax'. Previous versions used whatever your tar program
47
+ # used by default.
48
+ #
49
+ def initialize(archive_name, file_pattern = nil, program = nil, format = 'pax')
43
50
  @archive_name = archive_name.to_s
44
51
  @compressed_archive_name = nil
45
52
  @tar_program = 'tar'
53
+ @format = 'pax'
46
54
 
47
55
  create_archive(file_pattern) if file_pattern
48
56
  compress_archive(program) if program
@@ -67,12 +75,13 @@ module Archive
67
75
  end
68
76
 
69
77
  # Creates the archive using +file_pattern+ using +options+ or 'cf'
70
- # (create file) by default.
78
+ # (create file) by default. The 'f' option should always be present
79
+ # and always be last.
71
80
  #
72
81
  # Raises an Archive::Tar::Error if a failure occurs.
73
82
  #
74
83
  def create_archive(file_pattern, options = 'cf')
75
- cmd = "#{@tar_program} #{options} #{@archive_name} #{file_pattern}"
84
+ cmd = "#{@tar_program} --format #{@format} -#{options} #{@archive_name} #{file_pattern}"
76
85
 
77
86
  Open3.popen3(cmd) do |_tar_in, _tar_out, tar_err|
78
87
  err = tar_err.gets
@@ -15,20 +15,18 @@ RSpec.describe Archive::Tar::External do
15
15
  let(:tar_name) { 'test.tar' }
16
16
  let(:tar_obj) { Archive::Tar::External.new(tar_name) }
17
17
  let(:pattern) { '*.txt' }
18
- let(:gtar) { File.basename(File.which('gtar')) }
19
18
 
20
19
  let(:archive_name) { 'test.tar.gz' }
21
- let(:tar_program) { gtar || 'tar' }
20
+ let(:tar_program) { 'tar' }
22
21
 
23
22
  before do
24
- tar_obj.tar_program = 'gtar' if File.which('gtar')
25
23
  File.open(tmp_file1, 'w'){ |f| f.puts 'This is a temporary text file' }
26
24
  File.open(tmp_file2, 'w'){ |f| f.puts 'This is a temporary text file' }
27
25
  File.open(tmp_file3, 'w'){ |f| f.puts 'This is a temporary text file' }
28
26
  end
29
27
 
30
28
  example "version" do
31
- expect(Archive::Tar::External::VERSION).to eq('1.4.2')
29
+ expect(Archive::Tar::External::VERSION).to eq('1.5.0')
32
30
  expect(Archive::Tar::External::VERSION).to be_frozen
33
31
  end
34
32
 
@@ -102,13 +100,18 @@ RSpec.describe Archive::Tar::External do
102
100
  end
103
101
 
104
102
  example "create_archive accepts optional parameters" do
105
- expect{ tar_obj.create_archive(pattern, 'cfj') }.not_to raise_error
103
+ expect{ tar_obj.create_archive(pattern, 'jcf') }.not_to raise_error
106
104
  end
107
105
 
108
106
  example "create is an alias for create_archive" do
109
107
  expect(tar_obj).to respond_to(:create)
110
108
  expect(tar_obj.method(:create)).to eq(tar_obj.method(:create_archive))
111
109
  end
110
+
111
+ example "format getter" do
112
+ expect(tar_obj).to respond_to(:format)
113
+ expect(tar_obj.format).to eq('pax')
114
+ end
112
115
  end
113
116
 
114
117
  context "compression" do
@@ -185,7 +188,7 @@ RSpec.describe Archive::Tar::External do
185
188
  expect(tar_obj).to respond_to(:update_archive)
186
189
  end
187
190
 
188
- example "update_archive behaves as expected", :gtar => true do
191
+ example "update_archive behaves as expected" do
189
192
  tar_obj.create_archive(pattern)
190
193
  expect(tar_obj.archive_info).to eq([tmp_file1, tmp_file2, tmp_file3])
191
194
  tar_obj.update_archive(tmp_file2)
data/spec/spec_helper.rb CHANGED
@@ -3,5 +3,4 @@ require 'ptools'
3
3
 
4
4
  RSpec.configure do |config|
5
5
  config.filter_run_excluding(:gzip) unless File.which('gzip')
6
- config.filter_run_excluding(:gtar) unless File.which('gtar')
7
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archive-tar-external
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Berger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2021-04-30 00:00:00.000000000 Z
38
+ date: 2021-05-01 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
@@ -132,5 +132,5 @@ signing_key:
132
132
  specification_version: 4
133
133
  summary: A simple way to create tar archives using external calls
134
134
  test_files:
135
- - spec/archive_tar_external_spec.rb
136
135
  - spec/spec_helper.rb
136
+ - spec/archive_tar_external_spec.rb
metadata.gz.sig CHANGED
Binary file