archive-tar-external 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/MANIFEST +11 -0
- data/README +3 -8
- data/doc/tar_external.txt +4 -4
- data/lib/archive/tar_external.rb +252 -242
- data/test/tc_archive.rb +6 -11
- metadata +7 -3
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 1.2.1 - 30-Jul-2007
|
2
|
+
* The TarError class is now Tar::Error.
|
3
|
+
* Added a Rakefile with tasks for installation and testing.
|
4
|
+
* Removed the install.rb file. Installation is now handled by the Rakefile.
|
5
|
+
* Documentation updates.
|
6
|
+
|
1
7
|
== 1.2.0 - 7-Apr-2006
|
2
8
|
* Project renamed 'archive-tar-external'.
|
3
9
|
* The 'Tar' class is now Tar::External.
|
data/MANIFEST
ADDED
data/README
CHANGED
@@ -16,18 +16,13 @@
|
|
16
16
|
|
17
17
|
== Prerequisites
|
18
18
|
Ruby 1.8.0 or later.
|
19
|
-
The win32-open3 package (Windows only).
|
19
|
+
The win32-open3 package (MS Windows only).
|
20
20
|
The "tar" command line program.
|
21
21
|
At least one compression program, e.g. gzip, bzip2, zip, etc.
|
22
22
|
|
23
23
|
== Installation
|
24
|
-
|
25
|
-
|
26
|
-
ruby install.rb
|
27
|
-
|
28
|
-
=== Gem Installation
|
29
|
-
ruby archive-tar-external.gemspec
|
30
|
-
gem install archive-tar-external-XXX.gem
|
24
|
+
rake test (optional)
|
25
|
+
rake install (non-gem) or rake install_gem (gem)
|
31
26
|
|
32
27
|
== Notes
|
33
28
|
For further documentation and information, see the tar_external.txt file
|
data/doc/tar_external.txt
CHANGED
@@ -49,7 +49,7 @@ Archive::Tar::External.uncompress_archive(archive_name, program='gunzip')
|
|
49
49
|
Archive;:Tar#add(file1 [, file2, ...])
|
50
50
|
Archive::Tar::External#add_to_archive(file1 [, file2, ...])
|
51
51
|
Adds a list of files to the current archive. At least one file must be
|
52
|
-
provided or a
|
52
|
+
provided or a Tar::Error is raised.
|
53
53
|
|
54
54
|
Archive::Tar::External#archive_info
|
55
55
|
Archive::Tar::External#info
|
@@ -100,11 +100,11 @@ Archive::Tar::External#update_archive(files)
|
|
100
100
|
are not already in the archive or have been modified.
|
101
101
|
|
102
102
|
== Exceptions
|
103
|
-
|
103
|
+
Tar::Error
|
104
104
|
Raised if something goes wrong during the execution of any methods that
|
105
105
|
use the tar command internally.
|
106
106
|
|
107
|
-
CompressError
|
107
|
+
Tar::CompressError
|
108
108
|
Raised if something goes wrong during the Tar#compress_archive or
|
109
109
|
Tar#uncompress_archive methods.
|
110
110
|
|
@@ -127,7 +127,7 @@ CompressError
|
|
127
127
|
warranties of merchantability and fitness for a particular purpose.
|
128
128
|
|
129
129
|
== Copyright
|
130
|
-
(C) 2003 -
|
130
|
+
(C) 2003 - 2007 Daniel J. Berger
|
131
131
|
All Rights Reserved
|
132
132
|
|
133
133
|
== Author
|
data/lib/archive/tar_external.rb
CHANGED
@@ -1,277 +1,287 @@
|
|
1
|
-
if RUBY_PLATFORM.match(
|
2
|
-
require
|
1
|
+
if RUBY_PLATFORM.match('mswin')
|
2
|
+
require 'win32/open3'
|
3
3
|
else
|
4
|
-
require
|
4
|
+
require 'open3'
|
5
5
|
end
|
6
6
|
|
7
|
+
# The Archive module serves as a namespace only.
|
7
8
|
module Archive
|
8
9
|
|
9
|
-
class
|
10
|
-
class
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
10
|
+
# The Tar class serves as a toplevel class namespace only.
|
11
|
+
class Tar
|
12
|
+
|
13
|
+
# Raised if something goes wrong during the execution of any methods
|
14
|
+
# which use the tar command internally.
|
15
|
+
class Error < StandardError; end
|
16
|
+
|
17
|
+
# Raised if something goes wrong during the Tar#compress_archive or
|
18
|
+
# Tar#uncompress_archive methods.
|
19
|
+
class CompressError < StandardError; end
|
20
|
+
|
21
|
+
# This class encapsulates tar & zip operations.
|
22
|
+
class Tar::External
|
23
|
+
VERSION = '1.2.1'
|
24
|
+
|
25
|
+
# The name of the archive file to be used, e.g. "test.tar"
|
26
|
+
attr_accessor :archive_name
|
27
|
+
|
28
|
+
# The name of the tar program you wish to use. The default is "tar".
|
29
|
+
attr_accessor :tar_program
|
30
|
+
|
31
|
+
# The name of the archive file after compression, e.g. "test.tar.gz"
|
32
|
+
attr_reader :compressed_archive_name
|
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
|
36
|
+
# years of convention, it is not enforced.
|
37
|
+
#
|
38
|
+
# Note that this does not actually create the archive unless you
|
39
|
+
# pass a value to +file_pattern+. This then becomes a shortcut for
|
40
|
+
# Archive::Tar::External.new + Archive::Tar::External#create_archive.
|
41
|
+
#
|
42
|
+
# If +program+ is provided, then it compresses the archive as well by
|
43
|
+
# calling Archive::Tar::External#compress_archive internally.
|
44
|
+
#
|
45
|
+
def initialize(archive_name, file_pattern=nil, program=nil)
|
46
|
+
@archive_name = archive_name.to_s
|
47
|
+
@compressed_archive_name = nil
|
48
|
+
@tar_program = "tar"
|
44
49
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
50
|
+
if file_pattern
|
51
|
+
create_archive(file_pattern)
|
52
|
+
end
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
|
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)
|
54
|
+
if program
|
55
|
+
compress_archive(program)
|
56
|
+
end
|
64
57
|
end
|
65
|
-
@compressed_archive_name = name
|
66
|
-
end
|
67
58
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
59
|
+
# Assign a compressed archive name. This autogenerates the archive_name
|
60
|
+
# based on the extension of the name provided, unless you provide the
|
61
|
+
# extension yourself. If the extension is '.tgz', then the base of the
|
62
|
+
# name + '.tar' will be the new archive name.
|
63
|
+
#
|
64
|
+
# This should only be used if you have a pre-existing, compressed archive
|
65
|
+
# that you want to uncompress, and want to have a Tar::External object
|
66
|
+
# around. Otherwise, use the class method Tar::External.uncompress.
|
67
|
+
#
|
68
|
+
def compressed_archive_name=(name, ext=File.extname(name))
|
69
|
+
if ext == '.tgz' || ext == '.TGZ'
|
70
|
+
@archive_name = File.basename(name, ext.downcase) + '.tar'
|
71
|
+
else
|
72
|
+
@archive_name = File.basename(name, ext)
|
95
73
|
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
74
|
@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
75
|
end
|
120
|
-
|
121
|
-
cmd = "#{program} #{@compressed_archive_name}"
|
122
76
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
77
|
+
# Creates the archive using +file_pattern+. Any errors that occur
|
78
|
+
# here will raise a Error.
|
79
|
+
#
|
80
|
+
def create_archive(file_pattern)
|
81
|
+
cmd = "#{@tar_program} cf #{@archive_name} #{file_pattern}"
|
82
|
+
Open3.popen3(cmd){ |tar_in, tar_out, tar_err|
|
83
|
+
err = tar_err.gets
|
84
|
+
if err
|
85
|
+
raise Error, err.chomp
|
86
|
+
end
|
87
|
+
}
|
88
|
+
self
|
89
|
+
end
|
90
|
+
alias :create :create_archive
|
91
|
+
|
92
|
+
# Compresses the archive with +program+, or gzip if no program is
|
93
|
+
# provided. If you want to pass arguments to +program+, merely include
|
94
|
+
# them as part of the program name, e.g. "gzip -f".
|
95
|
+
#
|
96
|
+
# Any errors that occur here will raise a Tar::CompressError.
|
97
|
+
#
|
98
|
+
def compress_archive(program="gzip")
|
99
|
+
cmd = "#{program} #{@archive_name}"
|
100
|
+
Open3.popen3(cmd){ |prog_in, prog_out, prog_err|
|
101
|
+
err = prog_err.gets
|
102
|
+
if err
|
103
|
+
raise CompressError, err.chomp
|
104
|
+
end
|
105
|
+
|
106
|
+
# Find the new file name with the extension. There's probably a more
|
107
|
+
# reliable way to do this, but this should work 99% of the time.
|
108
|
+
name = Dir["#{@archive_name}.{gz,bz2,cpio,zip}"].first
|
109
|
+
@compressed_archive_name = name
|
110
|
+
}
|
111
|
+
self
|
112
|
+
end
|
113
|
+
alias :compress :compress_archive
|
114
|
+
|
115
|
+
# Uncompresses the tarball using the program you pass to this method. The
|
116
|
+
# default is "gunzip". Just as for +compress_archive+, you can pass
|
117
|
+
# arguments along as part of the argument.
|
118
|
+
#
|
119
|
+
# Note that this is only for use with archives that have been zipped up
|
120
|
+
# with gunzip, or whatever. If you want to *extract* the files from the
|
121
|
+
# tarball, use Tar::External#extract instead.
|
122
|
+
#
|
123
|
+
# Any errors that occur here will raise a Tar::CompressError.
|
124
|
+
#
|
125
|
+
def uncompress_archive(program="gunzip")
|
126
|
+
unless @compressed_archive_name
|
127
|
+
raise CompressError, "no compressed file found"
|
144
128
|
end
|
145
|
-
|
146
|
-
|
129
|
+
|
130
|
+
cmd = "#{program} #{@compressed_archive_name}"
|
131
|
+
|
132
|
+
Open3.popen3(cmd){ |prog_in, prog_out, prog_err|
|
133
|
+
err = prog_err.gets
|
134
|
+
if err
|
135
|
+
raise CompressError, err.chomp
|
136
|
+
end
|
137
|
+
@compressed_archive_name = nil
|
138
|
+
}
|
139
|
+
self
|
140
|
+
end
|
141
|
+
alias :uncompress :uncompress_archive
|
142
|
+
|
143
|
+
# Uncompress an existing archive, using +program+ to uncompress it.
|
144
|
+
# The default decompression program is gunzip.
|
145
|
+
#
|
146
|
+
def self.uncompress_archive(archive, program='gunzip')
|
147
|
+
cmd = "#{program} #{archive}"
|
148
|
+
|
149
|
+
Open3.popen3(cmd){ |prog_in, prog_out, prog_err|
|
150
|
+
err = prog_err.gets
|
151
|
+
if err
|
152
|
+
raise CompressError, err.chomp
|
153
|
+
end
|
154
|
+
}
|
155
|
+
end
|
147
156
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
157
|
+
# An alias for Tar::External.uncompress_archive.
|
158
|
+
#
|
159
|
+
def self.uncompress(file, program='gunzip')
|
160
|
+
self.uncompress_archive(file, program)
|
161
|
+
end
|
153
162
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
163
|
+
# Returns an array of file names that are included within the tarball.
|
164
|
+
# This method does not extract the archive.
|
165
|
+
#
|
166
|
+
def archive_info
|
167
|
+
result = []
|
168
|
+
cmd = "#{@tar_program} tf #{@archive_name}"
|
169
|
+
Open3.popen3(cmd){ |ain, aout, aerr|
|
170
|
+
err = aerr.gets
|
171
|
+
if err
|
172
|
+
raise Error, err.chomp
|
173
|
+
end
|
174
|
+
|
175
|
+
while output = aout.gets
|
176
|
+
result << output.chomp
|
177
|
+
end
|
178
|
+
}
|
179
|
+
result
|
180
|
+
end
|
181
|
+
alias :info :archive_info
|
165
182
|
|
166
|
-
|
167
|
-
|
183
|
+
# Adds +files+ to an already existing archive.
|
184
|
+
#
|
185
|
+
def add_to_archive(*files)
|
186
|
+
if files.empty?
|
187
|
+
raise Error, "there must be at least one file specified"
|
168
188
|
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
189
|
|
181
|
-
|
182
|
-
|
183
|
-
|
190
|
+
cmd = "#{@tar_program} rf #{@archive_name} #{files.join(" ")}"
|
191
|
+
Open3.popen3(cmd){ |ain, aout, aerr|
|
192
|
+
err = aerr.gets
|
184
193
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
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"
|
194
|
+
if err
|
195
|
+
raise Error, err.chomp
|
196
|
+
end
|
197
|
+
}
|
198
|
+
self
|
199
199
|
end
|
200
|
+
alias :add :add_to_archive
|
201
|
+
|
202
|
+
# Updates the given +files+ in the archive, i.e. they are added if they
|
203
|
+
# are not already in the archive or have been modified.
|
204
|
+
#
|
205
|
+
def update_archive(*files)
|
206
|
+
if files.empty?
|
207
|
+
raise Error, "there must be at least one file specified"
|
208
|
+
end
|
200
209
|
|
201
|
-
|
210
|
+
cmd = "#{@tar_program} uf #{@archive_name} #{files.join(" ")}"
|
202
211
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
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(" ")
|
212
|
+
Open3.popen3(cmd){ |ain, aout, aerr|
|
213
|
+
err = aerr.gets
|
214
|
+
if err
|
215
|
+
raise Error, err.chomp
|
216
|
+
end
|
217
|
+
}
|
218
|
+
self
|
226
219
|
end
|
220
|
+
alias :update :update_archive
|
221
|
+
|
222
|
+
# Expands the contents of the tarball. It does NOT delete the tarball.
|
223
|
+
# If +files+ are provided, then only those files are extracted.
|
224
|
+
# Otherwise, all files are extracted.
|
225
|
+
#
|
226
|
+
# Note that some tar programs, notably the tar program shipped by Sun,
|
227
|
+
# does not issue any sort of warning or error if you try to extract a
|
228
|
+
# file that does not exist in the archive.
|
229
|
+
#
|
230
|
+
def extract_archive(*files)
|
231
|
+
cmd = "#{@tar_program} xf #{@archive_name}"
|
232
|
+
|
233
|
+
unless files.empty?
|
234
|
+
cmd << " " << files.join(" ")
|
235
|
+
end
|
227
236
|
|
228
|
-
|
229
|
-
|
237
|
+
Open3.popen3(cmd){ |ain, aout, aerr|
|
238
|
+
err = aerr.gets
|
230
239
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
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(" ")
|
240
|
+
if err
|
241
|
+
raise Error, err.chomp
|
242
|
+
end
|
243
|
+
}
|
244
|
+
self
|
250
245
|
end
|
246
|
+
alias :expand_archive :extract_archive
|
247
|
+
alias :extract :extract_archive
|
248
|
+
alias :expand :extract_archive
|
249
|
+
|
250
|
+
# A class method that behaves identically to the equivalent instance
|
251
|
+
# method, except that you must specifiy that tarball as the first
|
252
|
+
# argument. Also, the tar program is hard coded to 'tar xf'.
|
253
|
+
#
|
254
|
+
def self.extract_archive(archive, *files)
|
255
|
+
cmd = "tar xf #{archive}"
|
256
|
+
|
257
|
+
unless files.empty?
|
258
|
+
cmd << " " << files.join(" ")
|
259
|
+
end
|
251
260
|
|
252
|
-
|
253
|
-
|
261
|
+
Open3.popen3(cmd){ |ain, aout, aerr|
|
262
|
+
err = aerr.gets
|
254
263
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
264
|
+
if err
|
265
|
+
raise Error, err.chomp
|
266
|
+
end
|
267
|
+
}
|
268
|
+
self
|
269
|
+
end
|
261
270
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
271
|
+
# Alias for self.extract_archive
|
272
|
+
def self.expand_archive(*args)
|
273
|
+
self.extract_archive(*args)
|
274
|
+
end
|
266
275
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
276
|
+
# Alias for self.extract_archive
|
277
|
+
def self.extract(*args)
|
278
|
+
self.extract_archive(*args)
|
279
|
+
end
|
271
280
|
|
272
|
-
|
273
|
-
|
274
|
-
|
281
|
+
# Alias for self.extract_archive
|
282
|
+
def self.expand(*args)
|
283
|
+
self.extract_archive(*args)
|
284
|
+
end
|
275
285
|
end
|
276
286
|
end
|
277
287
|
end
|
data/test/tc_archive.rb
CHANGED
@@ -1,21 +1,16 @@
|
|
1
1
|
###############################################################################
|
2
2
|
# tc_archive.rb
|
3
3
|
#
|
4
|
-
# Test suite for the archive-tarsimple package.
|
4
|
+
# Test suite for the archive-tarsimple package. This test case should be
|
5
|
+
# run via the 'rake test' Rake task.
|
5
6
|
###############################################################################
|
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
7
|
require 'archive/tar_external'
|
14
8
|
require 'test/unit'
|
15
9
|
include Archive
|
16
10
|
|
17
11
|
class TC_Archive < Test::Unit::TestCase
|
18
12
|
def setup
|
13
|
+
Dir.chdir('test') unless File.basename(Dir.pwd) == 'test'
|
19
14
|
@t = Tar::External.new('test.tar')
|
20
15
|
@tar_name = 'test.tar'
|
21
16
|
@pattern = '*.txt'
|
@@ -23,7 +18,7 @@ class TC_Archive < Test::Unit::TestCase
|
|
23
18
|
end
|
24
19
|
|
25
20
|
def test_version
|
26
|
-
assert_equal('1.2.
|
21
|
+
assert_equal('1.2.1', Tar::External::VERSION)
|
27
22
|
end
|
28
23
|
|
29
24
|
def test_constructor
|
@@ -67,7 +62,7 @@ class TC_Archive < Test::Unit::TestCase
|
|
67
62
|
assert_respond_to(@t, :create) # Alias
|
68
63
|
|
69
64
|
assert_raises(ArgumentError){ @t.create_archive }
|
70
|
-
assert_raises(
|
65
|
+
assert_raises(Tar::Error){ @t.create_archive('*.blah') }
|
71
66
|
|
72
67
|
assert_nothing_raised{ @t.create_archive(@pattern) }
|
73
68
|
assert(@t.create_archive(@pattern))
|
@@ -135,7 +130,7 @@ class TC_Archive < Test::Unit::TestCase
|
|
135
130
|
def test_extract_archive_advanced
|
136
131
|
@t.tar_program = 'gtar' if PLATFORM.match('solaris')
|
137
132
|
assert_nothing_raised{ @t.create('*.txt') }
|
138
|
-
assert_raises(
|
133
|
+
assert_raises(Tar::Error){ @t.expand('blah.txt') }
|
139
134
|
|
140
135
|
assert_nothing_raised{ @t.extract_archive }
|
141
136
|
assert_nothing_raised{ @t.extract_archive('temp2.txt') }
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: archive-tar-external
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date:
|
6
|
+
version: 1.2.1
|
7
|
+
date: 2007-07-30 00:00:00 -06:00
|
8
8
|
summary: A simple way to create tar archives using external calls
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- Daniel Berger
|
30
31
|
files:
|
@@ -37,6 +38,7 @@ files:
|
|
37
38
|
- test/temp3.txt
|
38
39
|
- README
|
39
40
|
- CHANGES
|
41
|
+
- MANIFEST
|
40
42
|
test_files:
|
41
43
|
- test/tc_archive.rb
|
42
44
|
rdoc_options: []
|
@@ -44,6 +46,8 @@ rdoc_options: []
|
|
44
46
|
extra_rdoc_files:
|
45
47
|
- README
|
46
48
|
- CHANGES
|
49
|
+
- MANIFEST
|
50
|
+
- doc/tar_external.txt
|
47
51
|
executables: []
|
48
52
|
|
49
53
|
extensions: []
|