archive-tar-external 1.3.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,234 @@
1
+ ###############################################################################
2
+ # archive_tar_external_spec.rb
3
+ #
4
+ # Tests for the archive-tar-external library. This test case should be
5
+ # run via the 'rake spec' Rake task.
6
+ ###############################################################################
7
+ require 'archive/tar/external'
8
+ require 'spec_helper'
9
+
10
+ RSpec.describe Archive::Tar::External do
11
+ let(:tmp_file1) { 'temp1.txt' }
12
+ let(:tmp_file2) { 'temp2.txt' }
13
+ let(:tmp_file3) { 'temp3.txt' }
14
+
15
+ let(:tar_name) { 'test.tar' }
16
+ let(:tar_obj) { Archive::Tar::External.new(tar_name) }
17
+ let(:pattern) { '*.txt' }
18
+
19
+ let(:archive_name) { 'test.tar.gz' }
20
+ let(:tar_program) { 'tar' }
21
+
22
+ before do
23
+ File.open(tmp_file1, 'w'){ |f| f.puts 'This is a temporary text file' }
24
+ File.open(tmp_file2, 'w'){ |f| f.puts 'This is a temporary text file' }
25
+ File.open(tmp_file3, 'w'){ |f| f.puts 'This is a temporary text file' }
26
+ end
27
+
28
+ example "version" do
29
+ expect(Archive::Tar::External::VERSION).to eq('1.5.0')
30
+ expect(Archive::Tar::External::VERSION).to be_frozen
31
+ end
32
+
33
+ context "constructor" do
34
+ example "with name" do
35
+ expect{ Archive::Tar::External.new(tar_name) }.not_to raise_error
36
+ end
37
+
38
+ example "with name and extension" do
39
+ expect{ Archive::Tar::External.new(tar_name, pattern) }.not_to raise_error
40
+ end
41
+
42
+ example "with compression program", :gzip => true do
43
+ expect{ Archive::Tar::External.new(tar_name, pattern, 'gzip') }.not_to raise_error
44
+ end
45
+
46
+ example "raises an error if name is not provided" do
47
+ expect{ Archive::Tar::External.new }.to raise_error(ArgumentError)
48
+ end
49
+ end
50
+
51
+ context "instance methods" do
52
+ example "tar_program getter" do
53
+ expect(tar_obj).to respond_to(:tar_program)
54
+ expect(tar_obj.tar_program).to eq(tar_program)
55
+ end
56
+
57
+ example "archive_name getter" do
58
+ expect(tar_obj).to respond_to(:archive_name)
59
+ expect(tar_obj.archive_name).to eq(tar_name)
60
+ end
61
+
62
+ example "archive_name setter" do
63
+ expect(tar_obj).to respond_to(:archive_name=)
64
+ expect{ tar_obj.archive_name = 'foo' }.not_to raise_error
65
+ expect(tar_obj.archive_name).to eq('foo')
66
+ end
67
+
68
+ example "compressed_archive_name getter" do
69
+ expect(tar_obj).to respond_to(:compressed_archive_name)
70
+ expect(tar_obj.compressed_archive_name).to be_nil
71
+ end
72
+
73
+ example "compressed_archive_name setter basic functionality" do
74
+ expect(tar_obj).to respond_to(:compressed_archive_name=)
75
+ expect{ tar_obj.compressed_archive_name = archive_name }.not_to raise_error
76
+ end
77
+
78
+ example "setting the compressed_archive_name also sets the archive name to the expected value" do
79
+ tar_obj.compressed_archive_name = archive_name
80
+ expect(tar_obj.compressed_archive_name).to eq(archive_name)
81
+ expect(tar_obj.archive_name).to eq(tar_name)
82
+
83
+ tar_obj.compressed_archive_name = 'test.tgz'
84
+ expect(tar_obj.compressed_archive_name).to eq('test.tgz')
85
+ expect(tar_obj.archive_name).to eq(tar_name)
86
+ end
87
+
88
+ example "create_archive basic functionality" do
89
+ expect(tar_obj).to respond_to(:create_archive)
90
+ expect{ tar_obj.create_archive(pattern) }.not_to raise_error
91
+ expect(File.exist?(tar_name)).to be true
92
+ end
93
+
94
+ example "create_archive requires at least on argument" do
95
+ expect{ tar_obj.create_archive }.to raise_error(ArgumentError)
96
+ end
97
+
98
+ example "create_archive raises an error if no files match the pattern" do
99
+ expect{ tar_obj.create_archive('*.blah') }.to raise_error(Archive::Tar::Error)
100
+ end
101
+
102
+ example "create_archive accepts optional parameters" do
103
+ expect{ tar_obj.create_archive(pattern, 'jcf') }.not_to raise_error
104
+ end
105
+
106
+ example "create is an alias for create_archive" do
107
+ expect(tar_obj).to respond_to(:create)
108
+ expect(tar_obj.method(:create)).to eq(tar_obj.method(:create_archive))
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
115
+ end
116
+
117
+ context "compression" do
118
+ example "compress_archive basic functionality" do
119
+ expect(tar_obj).to respond_to(:compress_archive)
120
+ end
121
+
122
+ example "compress is an alias for compress_archive" do
123
+ expect(tar_obj).to respond_to(:compress)
124
+ expect(tar_obj.method(:compress)).to eq(tar_obj.method(:compress_archive))
125
+ end
126
+
127
+ example "compress_archive defaults to gzip", :gzip => true do
128
+ tar_obj.create_archive(pattern)
129
+ tar_obj.compress_archive
130
+
131
+ expect(tar_obj.compressed_archive_name).to eq(archive_name)
132
+ expect(File.exist?(archive_name)).to be true
133
+ end
134
+
135
+ example "compress_archive works with bzip2", :bzip2 => true do
136
+ expect{ tar_obj.create_archive(pattern) }.not_to raise_error
137
+ expect{ tar_obj.compress_archive('bzip2') }.not_to raise_error
138
+ expect(File.exist?('test.tar.bz2')).to be true
139
+ end
140
+ end
141
+
142
+ context "uncompression" do
143
+ before do
144
+ tar_obj.create_archive(pattern).compress_archive
145
+ end
146
+
147
+ example "uncompress_archive basic functionality" do
148
+ expect(tar_obj).to respond_to(:uncompress_archive)
149
+ end
150
+
151
+ example "uncompress_archive behaves as expected" do
152
+ expect{ tar_obj.uncompress_archive }.not_to raise_error
153
+ expect(File.exist?(archive_name)).to be false
154
+ end
155
+
156
+ example "uncompress is an alias for uncompress_archive" do
157
+ expect(tar_obj).to respond_to(:uncompress)
158
+ expect(tar_obj.method(:uncompress)).to eq (tar_obj.method(:uncompress_archive))
159
+ end
160
+
161
+ example "uncompress_archive singleton method" do
162
+ expect(Archive::Tar::External).to respond_to(:uncompress_archive)
163
+ end
164
+ end
165
+
166
+ context "archive" do
167
+ example "archive_info basic functionality" do
168
+ expect(tar_obj).to respond_to(:archive_info)
169
+ end
170
+
171
+ example "archive_info returns the expected value" do
172
+ tar_obj.create_archive(pattern)
173
+ expect(tar_obj.archive_info).to eq([tmp_file1, tmp_file2, tmp_file3])
174
+ end
175
+
176
+ example "add_to_archive basic functionality" do
177
+ expect(tar_obj).to respond_to(:add_to_archive)
178
+ end
179
+
180
+ example "add_to_archive works as expected" do
181
+ tar_obj = described_class.new(tar_name)
182
+ expect{ tar_obj.add_to_archive(tmp_file2) }.not_to raise_error
183
+ expect{ tar_obj.add_to_archive(tmp_file2, tmp_file3) }.not_to raise_error
184
+ expect(tar_obj.archive_info).to eq([tmp_file2, tmp_file2, tmp_file3])
185
+ end
186
+
187
+ example "update_archive basic functionality" do
188
+ expect(tar_obj).to respond_to(:update_archive)
189
+ end
190
+
191
+ example "update_archive behaves as expected" do
192
+ tar_obj.create_archive(pattern)
193
+ expect(tar_obj.archive_info).to eq([tmp_file1, tmp_file2, tmp_file3])
194
+ tar_obj.update_archive(tmp_file2)
195
+ expect(tar_obj.archive_info).to eq([tmp_file1, tmp_file2, tmp_file3])
196
+ end
197
+
198
+ example "extract_archive_basic" do
199
+ expect(tar_obj).to respond_to(:extract_archive)
200
+ end
201
+
202
+ example "extract_archive raises an error if the file isn't in the archive" do
203
+ tar_obj.create(pattern)
204
+ expect{ tar_obj.expand('blah.txt') }.to raise_error(Archive::Tar::Error)
205
+ end
206
+
207
+ example "extract_archive with no arguments extracts all files" do
208
+ tar_obj.create(pattern)
209
+ expect{ tar_obj.extract_archive }.not_to raise_error
210
+ end
211
+
212
+ example "extract_archive with a valid file argument behaves as expected" do
213
+ tar_obj.create(pattern)
214
+ expect{ tar_obj.extract_archive(tmp_file2) }.not_to raise_error
215
+ end
216
+
217
+ example "expand_archive, expand and extract are aliases for extract_archive" do
218
+ expect(tar_obj.method(:expand_archive)).to eq(tar_obj.method(:extract_archive))
219
+ expect(tar_obj.method(:expand)).to eq(tar_obj.method(:extract_archive))
220
+ expect(tar_obj.method(:extract)).to eq(tar_obj.method(:extract_archive))
221
+ end
222
+ end
223
+
224
+ after do
225
+ File.delete(tmp_file1) if File.exist?(tmp_file1)
226
+ File.delete(tmp_file2) if File.exist?(tmp_file2)
227
+ File.delete(tmp_file3) if File.exist?(tmp_file3)
228
+
229
+ File.delete(tar_name) if File.exist?(tar_name)
230
+ File.delete("#{tar_name}.gz") if File.exist?("#{tar_name}.gz")
231
+ File.delete("#{tar_name}.bz2") if File.exist?("#{tar_name}.bz2")
232
+ File.delete("#{tar_name}.zip") if File.exist?("#{tar_name}.zip")
233
+ end
234
+ end
@@ -0,0 +1,6 @@
1
+ require 'rspec'
2
+ require 'ptools'
3
+
4
+ RSpec.configure do |config|
5
+ config.filter_run_excluding(:gzip) unless File.which('gzip')
6
+ end
metadata CHANGED
@@ -1,57 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archive-tar-external
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
- cert_chain: []
11
- date: 2014-03-14 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
14
+ cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
15
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
16
+ ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
17
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
18
+ A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
19
+ u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
20
+ 75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv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cAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
+ -----END CERTIFICATE-----
38
+ date: 2021-05-01 00:00:00.000000000 Z
12
39
  dependencies:
13
40
  - !ruby/object:Gem::Dependency
14
- name: test-unit
41
+ name: rake
15
42
  requirement: !ruby/object:Gem::Requirement
16
43
  requirements:
17
- - - '>='
44
+ - - ">="
18
45
  - !ruby/object:Gem::Version
19
46
  version: '0'
20
47
  type: :development
21
48
  prerelease: false
22
49
  version_requirements: !ruby/object:Gem::Requirement
23
50
  requirements:
24
- - - '>='
51
+ - - ">="
25
52
  - !ruby/object:Gem::Version
26
53
  version: '0'
27
54
  - !ruby/object:Gem::Dependency
28
- name: ptools
55
+ name: rspec
29
56
  requirement: !ruby/object:Gem::Requirement
30
57
  requirements:
31
- - - '>='
58
+ - - "~>"
32
59
  - !ruby/object:Gem::Version
33
- version: '0'
60
+ version: '3.9'
34
61
  type: :development
35
62
  prerelease: false
36
63
  version_requirements: !ruby/object:Gem::Requirement
37
64
  requirements:
38
- - - '>='
65
+ - - "~>"
39
66
  - !ruby/object:Gem::Version
40
- version: '0'
67
+ version: '3.9'
41
68
  - !ruby/object:Gem::Dependency
42
- name: rake
69
+ name: ptools
43
70
  requirement: !ruby/object:Gem::Requirement
44
71
  requirements:
45
- - - '>='
72
+ - - "~>"
46
73
  - !ruby/object:Gem::Version
47
- version: '0'
74
+ version: '1.4'
48
75
  type: :development
49
76
  prerelease: false
50
77
  version_requirements: !ruby/object:Gem::Requirement
51
78
  requirements:
52
- - - '>='
79
+ - - "~>"
53
80
  - !ruby/object:Gem::Version
54
- version: '0'
81
+ version: '1.4'
55
82
  description: |2
56
83
  The archive-tar-external is a simple wrapper interface for creating
57
84
  tar files using your system's tar command. You can also easily compress
@@ -60,43 +87,50 @@ description: |2
60
87
  email: djberg96@gmail.com
61
88
  executables: []
62
89
  extensions: []
63
- extra_rdoc_files:
64
- - README
65
- - CHANGES
66
- - MANIFEST
67
- - doc/tar_external.txt
90
+ extra_rdoc_files: []
68
91
  files:
69
- - CHANGES
70
- - MANIFEST
71
- - README
92
+ - CHANGES.md
93
+ - Gemfile
94
+ - LICENSE
95
+ - MANIFEST.md
96
+ - README.md
72
97
  - Rakefile
73
98
  - archive-tar-external.gemspec
74
- - doc/tar_external.txt
99
+ - certs/djberg96_pub.pem
100
+ - doc/archive_tar_external.md
101
+ - lib/archive-tar-external.rb
75
102
  - lib/archive/tar/external.rb
76
- - test/test_archive_tar_external.rb
77
- homepage: https://github.com/djberg96/archive-tar-external
103
+ - spec/archive_tar_external_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: http://github.com/djberg96/archive-tar-external
78
106
  licenses:
79
- - Artistic 2.0
80
- metadata: {}
81
- post_install_message:
107
+ - Apache-2.0
108
+ metadata:
109
+ homepage_uri: https://github.com/djberg96/archive-tar-external
110
+ bug_tracker_uri: https://github.com/djberg96/archive-tar-external/issues
111
+ changelog_uri: https://github.com/djberg96/archive-tar-external/blob/main/CHANGES
112
+ documentation_uri: https://github.com/djberg96/archive-tar-external/wiki
113
+ source_code_uri: https://github.com/djberg96/archive-tar-external
114
+ wiki_uri: https://github.com/djberg96/archive-tar-external/wiki
115
+ post_install_message:
82
116
  rdoc_options: []
83
117
  require_paths:
84
118
  - lib
85
119
  required_ruby_version: !ruby/object:Gem::Requirement
86
120
  requirements:
87
- - - '>='
121
+ - - ">="
88
122
  - !ruby/object:Gem::Version
89
123
  version: '0'
90
124
  required_rubygems_version: !ruby/object:Gem::Requirement
91
125
  requirements:
92
- - - '>='
126
+ - - ">="
93
127
  - !ruby/object:Gem::Version
94
128
  version: '0'
95
129
  requirements: []
96
- rubyforge_project:
97
- rubygems_version: 2.2.2
98
- signing_key:
130
+ rubygems_version: 3.2.15
131
+ signing_key:
99
132
  specification_version: 4
100
133
  summary: A simple way to create tar archives using external calls
101
134
  test_files:
102
- - test/test_archive_tar_external.rb
135
+ - spec/spec_helper.rb
136
+ - spec/archive_tar_external_spec.rb
metadata.gz.sig ADDED
Binary file
data/MANIFEST DELETED
@@ -1,8 +0,0 @@
1
- * MANIFEST
2
- * CHANGES
3
- * INSTALL
4
- * Rakefile
5
- * archive-tar-external.gemspec
6
- * doc/tar_external.txt
7
- * lib/archive/tar_external.rb
8
- * test/test_archive_tar_external.rb
data/README DELETED
@@ -1,43 +0,0 @@
1
- == Description
2
- A simple tar & compress library that nicely wraps external system calls.
3
-
4
- == Installation
5
- gem install archive-tar-external
6
-
7
- == Synopsis
8
- require 'archive/tar/external'
9
- include Archive
10
-
11
- # The long way
12
- t = Tar::External.new('test.tar')
13
- t.create_archive('*.rb')
14
- t.compress_archive('gzip')
15
-
16
- # The short way
17
- t = Tar::External.new('test.tar', '*.rb', 'gzip')
18
-
19
- == Prerequisites
20
- The 'tar' command line program.
21
- At least one compression program, e.g. gzip, bzip2, zip, etc.
22
-
23
- == Known Issues
24
- The tar program that comes with Solaris will not raise an error if you
25
- try to expand a file from an archive that does not contain that file.
26
-
27
- If you come across any other issues, please report them on the project
28
- page at https://github.com/djberg96/archive-tar-external.
29
-
30
- == License
31
- Artistic 2.0
32
-
33
- == Warranty
34
- This package is provided "as is" and without any express or
35
- implied warranties, including, without limitation, the implied
36
- warranties of merchantability and fitness for a particular purpose.
37
-
38
- == Copyright
39
- (C) 2003 - 2014 Daniel J. Berger
40
- All Rights Reserved
41
-
42
- == Author
43
- Daniel J. Berger