archive-tar-external 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,63 @@
1
+ == 1.2.0 - 7-Apr-2006
2
+ * Project renamed 'archive-tar-external'.
3
+ * The 'Tar' class is now Tar::External.
4
+ * The RAA project name is now tar-external.
5
+ * Added the Tar::External.uncompress_archive class method for archives
6
+ that already exist.
7
+ * Added the Tar::External.extract_archive class method for tarballs
8
+ that already exist.
9
+ * Added the Tar::External#compressed_archive_name= method.
10
+
11
+ == 1.1.1 - 1-Mar-2006
12
+ * Replaced PLATFORM with RUBY_PLATFORM since the former is deprecated
13
+ for Ruby 1.9/2.0.
14
+
15
+ == 1.1.0 - 10-Feb-2006
16
+ * Internal refactoring changes - now uses block form of Open3.popen3.
17
+ * Most methods now return self instead of true (better for chaining).
18
+ * Corresponding test suite changes.
19
+
20
+ == 1.0.0 - 1-Sep-2005
21
+ * Moved project to RubyForge.
22
+ * Modified the constructor to accept a file pattern. If present, becomes
23
+ a shortcut for Tar.new + Tar#create_archive.
24
+ * Constructor merely calls .to_s on the archive name, rather than validating
25
+ that it's a String argument.
26
+ * You can now specify the tar program you wish to use, e.g. "tar", "gtar", etc.
27
+ * Fixed a bug in Tar#uncompress_archive where it wasn't finding the appropriate
28
+ compressed archive name.
29
+ * Added aliases for most methods whereby you can omit the word "archive" in
30
+ the method name now, e.g. Tar#compress is an alias for Tar#compress_archive.
31
+ * Now more polite about closing open handles from Open3.
32
+ * The (rdoc) documentation is now inlined.
33
+ * Removed the tarsimple.rd and tarsimple.html files.
34
+ * Made most documentation rdoc friendly.
35
+ * Updated the README and MANIFEST files.
36
+ * Removed the INSTALL file. The installation instructions are now included
37
+ in the README file.
38
+ * Test suite updates.
39
+ * Added a gemspec.
40
+
41
+ == 0.3.0 - 10-Aug-2004
42
+ * Added the update_archive() method.
43
+ * The expand_archive() method has been renamed to extract_archive().
44
+ For backward's compatability, an alias remains so you may use
45
+ either method name.
46
+ * The extract_archive() method now accepts a list of file names as
47
+ an argument. If present, then only those file names are extracted.
48
+ If not, then the entire archive is extracted.
49
+ * Added corresponding tests and documentation updates.
50
+
51
+ == 0.2.0 - 9-Aug-2004
52
+ * Added the add_to_archive() method.
53
+ * Removed the VERSION() class method. Use the constant instead.
54
+ * Changed "TarException" and "CompressionException" to "TarError" and
55
+ "CompressError", respectively.
56
+ * Moved rd documentation into its own file under the 'doc' directory.
57
+ * Added unit tests and updated the docs.
58
+ * Removed the html file. You can generate that on your own if you
59
+ wish using the rd2 tool.
60
+ * Added warranty information.
61
+
62
+ == 0.1.0 - 24-Jan-2003
63
+ * Initial Release
data/README ADDED
@@ -0,0 +1,34 @@
1
+ == Description
2
+ A very simple tar/compress package that uses calls to external programs
3
+ to do the work.
4
+
5
+ == Synopsis
6
+ require "archive/tar_external"
7
+ include Archive
8
+
9
+ # The long way
10
+ t = Tar::External.new("test.tar")
11
+ t.create_archive("*.rb")
12
+ t.compress_archive("gzip")
13
+
14
+ # The short way
15
+ t = Tar::External.new("test.tar", "*.rb", "gzip")
16
+
17
+ == Prerequisites
18
+ Ruby 1.8.0 or later.
19
+ The win32-open3 package (Windows only).
20
+ The "tar" command line program.
21
+ At least one compression program, e.g. gzip, bzip2, zip, etc.
22
+
23
+ == Installation
24
+ === Standard Installation
25
+ ruby test/tc_archive.rb (optional)
26
+ ruby install.rb
27
+
28
+ === Gem Installation
29
+ ruby archive-tar-external.gemspec
30
+ gem install archive-tar-external-XXX.gem
31
+
32
+ == Notes
33
+ For further documentation and information, see the tar_external.txt file
34
+ in the 'doc' directory.
@@ -0,0 +1,136 @@
1
+ == Description
2
+ A simple tar interface using external system calls.
3
+
4
+ == Synopsis
5
+ # Assuming we have three .txt files, t1.txt, t2.txt, t3.txt ...
6
+ require 'archive/tar_external'
7
+ include Archive
8
+
9
+ t = Tar::External.new("myfile.tar")
10
+
11
+ t.create_archive("*.txt")
12
+ t.compress_archive("bzip2") # 'myfile.tar.bz2' now exists
13
+
14
+ t.uncompress_archive("bunzip2")
15
+
16
+ t.archive_name # "myfile.tar"
17
+ t.archive_info # ["t1.txt","t2.txt","t3.txt"]
18
+
19
+ t.add_to_archive("t4.txt","t5.txt")
20
+ t.expand_archive
21
+
22
+ == Constants
23
+ VERSION
24
+ Current version number of this package. This is a string.
25
+
26
+ == Class Methods
27
+ Archive::Tar::External.new(archive_name, pattern=nil, program=nil)
28
+ Creates an instance of an Archive::Tar::External object. The +archive_name+ is
29
+ the name of the tarball. While a '.tar' extension is recommended based on
30
+ years of convention, it is not enforced.
31
+
32
+ If +pattern+ is provided, then the Archive#create_archive method is called
33
+ internally.
34
+
35
+ If +program+ is provided, then the Archive#compress_archive method is
36
+ called internally.
37
+
38
+ Note that +archive_name+ name must be a String, or a TypeError is raised.
39
+
40
+ Archive::Tar::External.expand_archive(archive_name, *files)
41
+ Identical to the instance method of the same name, except that you must
42
+ specify the +archive_name+, and the tar program is hard coded to 'tar xf'.
43
+
44
+ Archive::Tar::External.uncompress_archive(archive_name, program='gunzip')
45
+ Identical to the instance method of the same name, except that you must
46
+ specify the +archive_name+ as the first argument.
47
+
48
+ == Instance Methods
49
+ Archive;:Tar#add(file1 [, file2, ...])
50
+ Archive::Tar::External#add_to_archive(file1 [, file2, ...])
51
+ Adds a list of files to the current archive. At least one file must be
52
+ provided or a TarError is raised.
53
+
54
+ Archive::Tar::External#archive_info
55
+ Archive::Tar::External#info
56
+ Returns an array of file names that are included within the tarball.
57
+
58
+ Archive::Tar::External#archive_name
59
+ Returns the current archive name.
60
+
61
+ Archive::Tar::External#archive_name=
62
+ Sets the current archive name.
63
+
64
+ Archive::Tar::External#compress(program="gzip")
65
+ Archive::Tar::External#compress_archive(program="gzip")
66
+ Compresses the tarball using the program you pass to this method. The
67
+ default is "gzip".
68
+
69
+ Note that any arguments you want to be passed along with the program can
70
+ simply be included as part of the program, e.g. "gzip -f".
71
+
72
+ Archive::Tar::External#create(file_pattern)
73
+ Archive::Tar::External#create_archive(file_pattern)
74
+ Creates a new tarball, including those files which match 'file_pattern'.
75
+
76
+ Archive::Tar::External#expand_archive(files=nil)
77
+ Archive::Tar::External#extract_archive(files=nil)
78
+ Expands the contents of the tarball. Note that this method does NOT delete
79
+ the tarball.
80
+
81
+ If file names are provided, then only those files are extracted.
82
+
83
+ Archive::Tar::External#tar_program
84
+ Returns the name of the tar program used. The default is "tar".
85
+
86
+ Archive::Tar::External#tar_program=(program_name)
87
+ Sets the name of the tar program to be used.
88
+
89
+ Archive::Tar::External#uncompress(program="gunzip")
90
+ Archive::Tar::External#uncompress_archive(program="gunzip")
91
+ Uncompresses the tarball using the program you pass to this method. The
92
+ default is "gunzip".
93
+
94
+ As for compress_archive(), you can pass arguments along as part of the
95
+ argument.
96
+
97
+ Archive::Tar::External#update(files)
98
+ Archive::Tar::External#update_archive(files)
99
+ Updates the given +files+ in the archive, i.e they are added if they
100
+ are not already in the archive or have been modified.
101
+
102
+ == Exceptions
103
+ TarError
104
+ Raised if something goes wrong during the execution of any methods that
105
+ use the tar command internally.
106
+
107
+ CompressError
108
+ Raised if something goes wrong during the Tar#compress_archive or
109
+ Tar#uncompress_archive methods.
110
+
111
+ == Known Issues
112
+ The tar program that comes with Solaris will not raise an error if you
113
+ try to expand a file from an archive that does not contain that file.
114
+
115
+ If you come across any other issues, please report them on the project
116
+ page at http://www.rubyforge.org/projects/shards.
117
+
118
+ == Future Plans
119
+ Anything folks are looking for?
120
+
121
+ == License
122
+ Ruby's
123
+
124
+ == Warranty
125
+ This package is provided "as is" and without any express or
126
+ implied warranties, including, without limitation, the implied
127
+ warranties of merchantability and fitness for a particular purpose.
128
+
129
+ == Copyright
130
+ (C) 2003 - 2006 Daniel J. Berger
131
+ All Rights Reserved
132
+
133
+ == Author
134
+ Daniel J. Berger
135
+ djberg96 at gmail dot com
136
+ imperator on IRC (freenode)
@@ -0,0 +1,277 @@
1
+ if RUBY_PLATFORM.match("mswin")
2
+ require "win32/open3"
3
+ else
4
+ require "open3"
5
+ end
6
+
7
+ module Archive
8
+
9
+ class TarError < StandardError; end
10
+ class CompressError < StandardError; end
11
+ class Tar; end # Dummy, so our nesting/scoping works properly.
12
+
13
+ class Tar::External
14
+ VERSION = '1.2.0'
15
+
16
+ # The name of the archive file to be used, e.g. "test.tar"
17
+ attr_accessor :archive_name
18
+
19
+ # The name of the tar program you wish to use. The default is "tar".
20
+ attr_accessor :tar_program
21
+
22
+ # The name of the archive file after compression, e.g. "test.tar.gz"
23
+ attr_reader :compressed_archive_name
24
+
25
+ # Returns an Archive::Tar::External object. The +archive_name+ is the
26
+ # name of the tarball. While a .tar extension is recommended based on
27
+ # years of convention, it is not enforced.
28
+ #
29
+ # Note that this does not actually create the archive unless you
30
+ # pass a value to +file_pattern+. This then becomes a shortcut for
31
+ # Archive::Tar::External.new + Archive::Tar::External#create_archive.
32
+ #
33
+ # If +program+ is provided, then it compresses the archive as well by
34
+ # calling Archive::Tar::External#compress_archive internally.
35
+ #
36
+ def initialize(archive_name, file_pattern=nil, program=nil)
37
+ @archive_name = archive_name.to_s
38
+ @compressed_archive_name = nil
39
+ @tar_program = "tar"
40
+
41
+ if file_pattern
42
+ create_archive(file_pattern)
43
+ end
44
+
45
+ if program
46
+ compress_archive(program)
47
+ end
48
+ end
49
+
50
+ # Assign a compressed archive name. This autogenerates the archive_name
51
+ # based on the extension of the name provided, unless you provide the
52
+ # extension yourself. If the extension is '.tgz', then the base of the
53
+ # name + '.tar' will be the new archive name.
54
+ #
55
+ # This should only be used if you have a pre-existing, compressed archive
56
+ # that you want to uncompress, and want to have a Tar::External object
57
+ # around. Otherwise, use the class method Tar::External.uncompress.
58
+ #
59
+ def compressed_archive_name=(name, ext=File.extname(name))
60
+ if ext == '.tgz' || ext == '.TGZ'
61
+ @archive_name = File.basename(name, ext.downcase) + '.tar'
62
+ else
63
+ @archive_name = File.basename(name, ext)
64
+ end
65
+ @compressed_archive_name = name
66
+ end
67
+
68
+ # Creates the archive using +file_pattern+. Any errors that occur
69
+ # here will raise a TarError.
70
+ #
71
+ def create_archive(file_pattern)
72
+ cmd = "#{@tar_program} cf #{@archive_name} #{file_pattern}"
73
+ Open3.popen3(cmd){ |tar_in, tar_out, tar_err|
74
+ err = tar_err.gets
75
+ if err
76
+ raise TarError, err.chomp
77
+ end
78
+ }
79
+ self
80
+ end
81
+ alias :create :create_archive
82
+
83
+ # Compresses the archive with +program+, or gzip if no program is
84
+ # provided. If you want to pass arguments to +program+, merely include
85
+ # them as part of the program name, e.g. "gzip -f".
86
+ #
87
+ # Any errors that occur here will raise a CompressError.
88
+ #
89
+ def compress_archive(program="gzip")
90
+ cmd = "#{program} #{@archive_name}"
91
+ Open3.popen3(cmd){ |prog_in, prog_out, prog_err|
92
+ err = prog_err.gets
93
+ if err
94
+ raise CompressError, err.chomp
95
+ end
96
+
97
+ # Find the new file name with the extension. There's probably a more
98
+ # reliable way to do this, but this should work 99% of the time.
99
+ name = Dir["#{@archive_name}.{gz,bz2,cpio,zip}"].first
100
+ @compressed_archive_name = name
101
+ }
102
+ self
103
+ end
104
+ alias :compress :compress_archive
105
+
106
+ # Uncompresses the tarball using the program you pass to this method. The
107
+ # default is "gunzip". Just as for +compress_archive+, you can pass
108
+ # arguments along as part of the argument.
109
+ #
110
+ # Note that this is only for use with archives that have been zipped up
111
+ # with gunzip, or whatever. If you want to *extract* the files from the
112
+ # tarball, use Tar::External#extract instead.
113
+ #
114
+ # Any errors that occur here will raise a CompressError.
115
+ #
116
+ def uncompress_archive(program="gunzip")
117
+ unless @compressed_archive_name
118
+ raise CompressError, "no compressed file found"
119
+ end
120
+
121
+ cmd = "#{program} #{@compressed_archive_name}"
122
+
123
+ Open3.popen3(cmd){ |prog_in, prog_out, prog_err|
124
+ err = prog_err.gets
125
+ if err
126
+ raise CompressError, err.chomp
127
+ end
128
+ @compressed_archive_name = nil
129
+ }
130
+ self
131
+ end
132
+ alias :uncompress :uncompress_archive
133
+
134
+ # Uncompress an existing archive, using +program+ to uncompress it.
135
+ # The default decompression program is gunzip.
136
+ #
137
+ def self.uncompress_archive(archive, program='gunzip')
138
+ cmd = "#{program} #{archive}"
139
+
140
+ Open3.popen3(cmd){ |prog_in, prog_out, prog_err|
141
+ err = prog_err.gets
142
+ if err
143
+ raise CompressError, err.chomp
144
+ end
145
+ }
146
+ end
147
+
148
+ # An alias for Tar::External.uncompress_archive.
149
+ #
150
+ def self.uncompress(file, program='gunzip')
151
+ self.uncompress_archive(file, program)
152
+ end
153
+
154
+ # Returns an array of file names that are included within the tarball.
155
+ # This method does not extract the archive.
156
+ #
157
+ def archive_info
158
+ result = []
159
+ cmd = "#{@tar_program} tf #{@archive_name}"
160
+ Open3.popen3(cmd){ |ain, aout, aerr|
161
+ err = aerr.gets
162
+ if err
163
+ raise TarError, err.chomp
164
+ end
165
+
166
+ while output = aout.gets
167
+ result << output.chomp
168
+ end
169
+ }
170
+ result
171
+ end
172
+ alias :info :archive_info
173
+
174
+ # Adds +files+ to an already existing archive.
175
+ #
176
+ def add_to_archive(*files)
177
+ if files.empty?
178
+ raise TarError, "there must be at least one file specified"
179
+ end
180
+
181
+ cmd = "#{@tar_program} rf #{@archive_name} #{files.join(" ")}"
182
+ Open3.popen3(cmd){ |ain, aout, aerr|
183
+ err = aerr.gets
184
+
185
+ if err
186
+ raise TarError, err.chomp
187
+ end
188
+ }
189
+ self
190
+ end
191
+ alias :add :add_to_archive
192
+
193
+ # Updates the given +files+ in the archive, i.e. they are added if they
194
+ # are not already in the archive or have been modified.
195
+ #
196
+ def update_archive(*files)
197
+ if files.empty?
198
+ raise TarError, "there must be at least one file specified"
199
+ end
200
+
201
+ cmd = "#{@tar_program} uf #{@archive_name} #{files.join(" ")}"
202
+
203
+ Open3.popen3(cmd){ |ain, aout, aerr|
204
+ err = aerr.gets
205
+ if err
206
+ raise TarError, err.chomp
207
+ end
208
+ }
209
+ self
210
+ end
211
+ alias :update :update_archive
212
+
213
+ # Expands the contents of the tarball. It does NOT delete the tarball.
214
+ # If +files+ are provided, then only those files are extracted.
215
+ # Otherwise, all files are extracted.
216
+ #
217
+ # Note that some tar programs, notably the tar program shipped by Sun,
218
+ # does not issue any sort of warning or error if you try to extract a
219
+ # file that does not exist in the archive.
220
+ #
221
+ def extract_archive(*files)
222
+ cmd = "#{@tar_program} xf #{@archive_name}"
223
+
224
+ unless files.empty?
225
+ cmd << " " << files.join(" ")
226
+ end
227
+
228
+ Open3.popen3(cmd){ |ain, aout, aerr|
229
+ err = aerr.gets
230
+
231
+ if err
232
+ raise TarError, err.chomp
233
+ end
234
+ }
235
+ self
236
+ end
237
+ alias :expand_archive :extract_archive
238
+ alias :extract :extract_archive
239
+ alias :expand :extract_archive
240
+
241
+ # A class method that behaves identically to the equivalent instance
242
+ # method, except that you must specifiy that tarball as the first
243
+ # argument. Also, the tar program is hard coded to 'tar xf'.
244
+ #
245
+ def self.extract_archive(archive, *files)
246
+ cmd = "tar xf #{archive}"
247
+
248
+ unless files.empty?
249
+ cmd << " " << files.join(" ")
250
+ end
251
+
252
+ Open3.popen3(cmd){ |ain, aout, aerr|
253
+ err = aerr.gets
254
+
255
+ if err
256
+ raise TarError, err.chomp
257
+ end
258
+ }
259
+ self
260
+ end
261
+
262
+ # Alias for self.extract_archive
263
+ def self.expand_archive(*args)
264
+ self.extract_archive(*args)
265
+ end
266
+
267
+ # Alias for self.extract_archive
268
+ def self.extract(*args)
269
+ self.extract_archive(*args)
270
+ end
271
+
272
+ # Alias for self.extract_archive
273
+ def self.expand(*args)
274
+ self.extract_archive(*args)
275
+ end
276
+ end
277
+ end
@@ -0,0 +1,158 @@
1
+ ###############################################################################
2
+ # tc_archive.rb
3
+ #
4
+ # Test suite for the archive-tarsimple package.
5
+ ###############################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /archive-tar-external/i
8
+ Dir.chdir('..') if base == 'test'
9
+ $LOAD_PATH.unshift(Dir.pwd + '/lib')
10
+ Dir.chdir('test') rescue nil
11
+ end
12
+
13
+ require 'archive/tar_external'
14
+ require 'test/unit'
15
+ include Archive
16
+
17
+ class TC_Archive < Test::Unit::TestCase
18
+ def setup
19
+ @t = Tar::External.new('test.tar')
20
+ @tar_name = 'test.tar'
21
+ @pattern = '*.txt'
22
+ @archive = 'temp.tar.gz'
23
+ end
24
+
25
+ def test_version
26
+ assert_equal('1.2.0', Tar::External::VERSION)
27
+ end
28
+
29
+ def test_constructor
30
+ assert_nothing_raised{ Tar::External.new(@tar_name) }
31
+ assert_nothing_raised{ Tar::External.new(@tar_name, '*.txt') }
32
+ assert_raises(ArgumentError){ Tar::External.new }
33
+ end
34
+
35
+ def test_tar_program
36
+ assert_respond_to(@t, :tar_program)
37
+ assert_equal('tar', @t.tar_program)
38
+ end
39
+
40
+ def test_archive_name
41
+ assert_respond_to(@t, :archive_name)
42
+ assert_respond_to(@t, :archive_name=)
43
+
44
+ assert_equal('test.tar', @t.archive_name)
45
+ assert_nothing_raised{ @t.archive_name }
46
+ assert_nothing_raised{ @t.archive_name = 'foo' }
47
+ end
48
+
49
+ def test_compressed_archive_name_get
50
+ assert_respond_to(@t, :compressed_archive_name)
51
+ assert_nil(@t.compressed_archive_name)
52
+ end
53
+
54
+ def test_compressed_archive_name_set
55
+ assert_respond_to(@t, :compressed_archive_name=)
56
+ assert_nothing_raised{ @t.compressed_archive_name = 'test.tar.gz' }
57
+ assert_equal('test.tar.gz', @t.compressed_archive_name)
58
+ assert_equal('test.tar', @t.archive_name)
59
+
60
+ assert_nothing_raised{ @t.compressed_archive_name = 'test.tgz' }
61
+ assert_equal('test.tgz', @t.compressed_archive_name)
62
+ assert_equal('test.tar', @t.archive_name)
63
+ end
64
+
65
+ def test_create_archive_basic
66
+ assert_respond_to(@t, :create_archive)
67
+ assert_respond_to(@t, :create) # Alias
68
+
69
+ assert_raises(ArgumentError){ @t.create_archive }
70
+ assert_raises(TarError){ @t.create_archive('*.blah') }
71
+
72
+ assert_nothing_raised{ @t.create_archive(@pattern) }
73
+ assert(@t.create_archive(@pattern))
74
+ assert(File.exists?(@tar_name))
75
+ end
76
+
77
+ def test_compress_archive_basic
78
+ assert_respond_to(@t, :compress_archive)
79
+ assert_respond_to(@t, :compress) # Alias
80
+ end
81
+
82
+ def test_compress_archive_gzip
83
+ assert_nothing_raised{ @t.create_archive('*.txt') }
84
+ assert_nothing_raised{ @t.compress_archive }
85
+
86
+ assert_equal('test.tar.gz', @t.compressed_archive_name)
87
+ assert(File.exists?('test.tar.gz'))
88
+ end
89
+
90
+ def test_compress_archive_bzip2
91
+ assert_nothing_raised{ @t.create_archive('*.txt') }
92
+ assert_nothing_raised{ @t.compress_archive('bzip2') }
93
+ assert(File.exists?('test.tar.bz2'))
94
+ end
95
+
96
+ def test_uncompress_archive
97
+ assert_respond_to(@t, :uncompress_archive)
98
+ assert_nothing_raised{ @t.create_archive('*.txt') }
99
+ assert_nothing_raised{ @t.compress_archive }
100
+ assert_nothing_raised{ @t.uncompress_archive }
101
+ assert(!File.exists?('test.tar.gz'))
102
+ end
103
+
104
+ def test_uncompress_archive_class_method
105
+ assert_respond_to(Tar::External, :uncompress_archive)
106
+ assert_respond_to(Tar::External, :uncompress)
107
+ end
108
+
109
+ def test_archive_info
110
+ assert_respond_to(@t, :archive_info)
111
+ assert_nothing_raised{ @t.create_archive('*.txt') }
112
+ assert_equal(['temp1.txt','temp2.txt','temp3.txt'], @t.archive_info)
113
+ end
114
+
115
+ def test_add_to_archive
116
+ assert_respond_to(@t,:add_to_archive)
117
+ assert_nothing_raised{ @t.create_archive('temp1.txt') }
118
+ assert_nothing_raised{ @t.add_to_archive('temp2.txt') }
119
+ assert_nothing_raised{ @t.add_to_archive('temp2.txt','temp3.txt') }
120
+ end
121
+
122
+ def test_update_archive
123
+ assert_respond_to(@t, :update_archive)
124
+ assert_nothing_raised{ @t.create_archive('*.txt') }
125
+ assert_nothing_raised{ @t.update_archive('temp2.txt') }
126
+ end
127
+
128
+ def test_extract_archive_basic
129
+ assert_respond_to(@t, :extract_archive)
130
+ assert_respond_to(@t, :expand_archive) # Alias
131
+ assert_respond_to(@t, :extract) # Alias
132
+ assert_respond_to(@t, :expand) # Alias
133
+ end
134
+
135
+ def test_extract_archive_advanced
136
+ @t.tar_program = 'gtar' if PLATFORM.match('solaris')
137
+ assert_nothing_raised{ @t.create('*.txt') }
138
+ assert_raises(TarError){ @t.expand('blah.txt') }
139
+
140
+ assert_nothing_raised{ @t.extract_archive }
141
+ assert_nothing_raised{ @t.extract_archive('temp2.txt') }
142
+ end
143
+
144
+ def test_extract_archive_class_method
145
+ assert_respond_to(Tar::External, :extract_archive)
146
+ assert_respond_to(Tar::External, :expand_archive)
147
+ assert_respond_to(Tar::External, :extract)
148
+ assert_respond_to(Tar::External, :expand)
149
+ end
150
+
151
+ def teardown
152
+ @t = nil
153
+ File.unlink('test.tar') if File.exists?('test.tar')
154
+ File.unlink('test.tar.gz') if File.exists?('test.tar.gz')
155
+ File.unlink('test.tar.bz2') if File.exists?('test.tar.bz2')
156
+ File.unlink('test.tar.zip') if File.exists?('test.tar.zip')
157
+ end
158
+ end
@@ -0,0 +1 @@
1
+ This is a temporary text file
@@ -0,0 +1,4 @@
1
+ This is a temporary text file
2
+ It is only used for testing
3
+ It is only used for testing
4
+ Feel free to delete these later
@@ -0,0 +1,3 @@
1
+ This is a temporary text file
2
+ It is only used for testing
3
+ Feel free to delete these later
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: archive-tar-external
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.2.0
7
+ date: 2006-04-07 00:00:00 -06:00
8
+ summary: A simple way to create tar archives using external calls
9
+ require_paths:
10
+ - lib
11
+ email: djberg96@gmail.com
12
+ homepage: http://www.rubyforge.org/shards
13
+ rubyforge_project:
14
+ description: A simple way to create tar archives using external calls
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Daniel Berger
30
+ files:
31
+ - doc/tar_external.txt
32
+ - lib/archive
33
+ - lib/archive/tar_external.rb
34
+ - test/tc_archive.rb
35
+ - test/temp1.txt
36
+ - test/temp2.txt
37
+ - test/temp3.txt
38
+ - README
39
+ - CHANGES
40
+ test_files:
41
+ - test/tc_archive.rb
42
+ rdoc_options: []
43
+
44
+ extra_rdoc_files:
45
+ - README
46
+ - CHANGES
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ requirements: []
52
+
53
+ dependencies: []
54
+