archive-tar-external 1.3.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
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,47 +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 win32-open3 library (MS Windows only).
21
- The 'tar' command line program.
22
- At least one compression program, e.g. gzip, bzip2, zip, etc.
23
-
24
- == Known Issues
25
- The tar program that comes with Solaris will not raise an error if you
26
- try to expand a file from an archive that does not contain that file.
27
-
28
- If you come across any other issues, please report them on the project
29
- page at http://www.rubyforge.org/projects/shards.
30
-
31
- == Future Plans
32
- Anything folks are looking for?
33
-
34
- == License
35
- Artistic 2.0
36
-
37
- == Warranty
38
- This package is provided "as is" and without any express or
39
- implied warranties, including, without limitation, the implied
40
- warranties of merchantability and fitness for a particular purpose.
41
-
42
- == Copyright
43
- (C) 2003 - 2011 Daniel J. Berger
44
- All Rights Reserved
45
-
46
- == Author
47
- Daniel J. Berger
data/doc/tar_external.txt DELETED
@@ -1,109 +0,0 @@
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 library. 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 Tar::Error 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
- Tar::Error
104
- Raised if something goes wrong during the execution of any methods that
105
- use the tar command internally.
106
-
107
- Tar::CompressError
108
- Raised if something goes wrong during the Tar#compress_archive or
109
- Tar#uncompress_archive methods.
@@ -1,203 +0,0 @@
1
- ###############################################################################
2
- # test_archive_tar_external.rb
3
- #
4
- # Test suite for the archive-tar-external library. This test case should be
5
- # run via the 'rake test' Rake task.
6
- ###############################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'archive/tar/external'
11
- require 'test/unit'
12
- require 'ptools'
13
- include Archive
14
-
15
- class TC_ArchiveTarExternal < Test::Unit::TestCase
16
- def self.startup
17
- Dir.chdir(File.dirname(File.expand_path(__FILE__)))
18
-
19
- @@tmp_file1 = 'temp1.txt'
20
- @@tmp_file2 = 'temp2.txt'
21
- @@tmp_file3 = 'temp3.txt'
22
-
23
- @@gtar_found = File.which('gtar')
24
- @@tar_found = File.which('tar')
25
- @@gzip_found = File.which('gzip')
26
- @@bzip2_found = File.which('bzip2')
27
-
28
- File.open(@@tmp_file1, 'w'){ |f| f.puts 'This is a temporary text file' }
29
- File.open(@@tmp_file2, 'w'){ |f| f.puts 'This is a temporary text file' }
30
- File.open(@@tmp_file3, 'w'){ |f| f.puts 'This is a temporary text file' }
31
- end
32
-
33
- def setup
34
- @tar = Tar::External.new('test.tar')
35
- @tar_name = 'test.tar'
36
- @pattern = '*.txt'
37
- @archive = 'temp.tar.gz'
38
- end
39
-
40
- def test_version
41
- assert_equal('1.3.1', Tar::External::VERSION)
42
- end
43
-
44
- def test_constructor
45
- assert_nothing_raised{ Tar::External.new(@tar_name) }
46
- end
47
-
48
- def test_constructor_with_extension
49
- assert_nothing_raised{ Tar::External.new(@tar_name, '*.txt') }
50
- end
51
-
52
- def test_constructor_with_program
53
- omit_unless(@@gzip_found){ 'gzip program not found - skipping' }
54
- assert_nothing_raised{ Tar::External.new(@tar_name, '*.txt', 'gzip') }
55
- end
56
-
57
- def test_constructor_expected_errors
58
- assert_raise(ArgumentError){ Tar::External.new }
59
- end
60
-
61
- def test_tar_program
62
- assert_respond_to(@tar, :tar_program)
63
- assert_equal('tar', @tar.tar_program)
64
- end
65
-
66
- def test_archive_name
67
- assert_respond_to(@tar, :archive_name)
68
- assert_respond_to(@tar, :archive_name=)
69
-
70
- assert_equal('test.tar', @tar.archive_name)
71
- assert_nothing_raised{ @tar.archive_name }
72
- assert_nothing_raised{ @tar.archive_name = 'foo' }
73
- end
74
-
75
- def test_compressed_archive_name_get
76
- assert_respond_to(@tar, :compressed_archive_name)
77
- assert_nil(@tar.compressed_archive_name)
78
- end
79
-
80
- def test_compressed_archive_name_set
81
- assert_respond_to(@tar, :compressed_archive_name=)
82
- assert_nothing_raised{ @tar.compressed_archive_name = 'test.tar.gz' }
83
- assert_equal('test.tar.gz', @tar.compressed_archive_name)
84
- assert_equal('test.tar', @tar.archive_name)
85
-
86
- assert_nothing_raised{ @tar.compressed_archive_name = 'test.tgz' }
87
- assert_equal('test.tgz', @tar.compressed_archive_name)
88
- assert_equal('test.tar', @tar.archive_name)
89
- end
90
-
91
- def test_create_archive_basic
92
- assert_respond_to(@tar, :create_archive)
93
-
94
- assert_raises(ArgumentError){ @tar.create_archive }
95
- assert_raises(Tar::Error){ @tar.create_archive('*.blah') }
96
-
97
- assert_nothing_raised{ @tar.create_archive(@pattern) }
98
- assert_true(File.exists?(@tar_name))
99
- end
100
-
101
- def test_create_alias
102
- assert_respond_to(@tar, :create)
103
- assert_true(Tar::External.instance_method(:create) == Tar::External.instance_method(:create_archive))
104
- end
105
-
106
- def test_compress_archive_basic
107
- assert_respond_to(@tar, :compress_archive)
108
- end
109
-
110
- def test_compress_alias
111
- assert_respond_to(@tar, :compress)
112
- assert_true(Tar::External.instance_method(:compress) == Tar::External.instance_method(:compress_archive))
113
- end
114
-
115
- def test_compress_archive_gzip
116
- assert_nothing_raised{ @tar.create_archive('*.txt') }
117
- assert_nothing_raised{ @tar.compress_archive }
118
-
119
- assert_equal('test.tar.gz', @tar.compressed_archive_name)
120
- assert_true(File.exists?('test.tar.gz'))
121
- end
122
-
123
- def test_compress_archive_bzip2
124
- assert_nothing_raised{ @tar.create_archive('*.txt') }
125
- assert_nothing_raised{ @tar.compress_archive('bzip2') }
126
- assert_true(File.exists?('test.tar.bz2'))
127
- end
128
-
129
- def test_uncompress_archive
130
- assert_respond_to(@tar, :uncompress_archive)
131
- assert_nothing_raised{ @tar.create_archive('*.txt') }
132
- assert_nothing_raised{ @tar.compress_archive }
133
- assert_nothing_raised{ @tar.uncompress_archive }
134
- assert_false(File.exists?('test.tar.gz'))
135
- end
136
-
137
- def test_uncompress_archive_class_method
138
- assert_respond_to(Tar::External, :uncompress_archive)
139
- end
140
-
141
- def test_uncompress_alias
142
- assert_respond_to(Tar::External, :uncompress)
143
- assert_true(Tar::External.method(:uncompress) == Tar::External.method(:uncompress_archive))
144
- end
145
-
146
- def test_archive_info
147
- assert_respond_to(@tar, :archive_info)
148
- assert_nothing_raised{ @tar.create_archive('*.txt') }
149
- assert_equal(['temp1.txt','temp2.txt','temp3.txt'], @tar.archive_info)
150
- end
151
-
152
- def test_add_to_archive
153
- assert_respond_to(@tar,:add_to_archive)
154
- assert_nothing_raised{ @tar.create_archive('temp1.txt') }
155
- assert_nothing_raised{ @tar.add_to_archive('temp2.txt') }
156
- assert_nothing_raised{ @tar.add_to_archive('temp2.txt','temp3.txt') }
157
- end
158
-
159
- def test_update_archive
160
- assert_respond_to(@tar, :update_archive)
161
- assert_nothing_raised{ @tar.create_archive('*.txt') }
162
- assert_nothing_raised{ @tar.update_archive('temp2.txt') }
163
- end
164
-
165
- def test_extract_archive_basic
166
- assert_respond_to(@tar, :extract_archive)
167
- end
168
-
169
- def test_extract_archive_aliases
170
- assert_true(Tar::External.instance_method(:extract_archive) == Tar::External.instance_method(:expand_archive))
171
- assert_true(Tar::External.instance_method(:extract) == Tar::External.instance_method(:expand_archive))
172
- assert_true(Tar::External.instance_method(:expand) == Tar::External.instance_method(:expand_archive))
173
- end
174
-
175
- def test_extract_archive_advanced
176
- omit_unless(Config::CONFIG['host_os'] =~ /sunos|solaris/){
177
- assert_nothing_raised{ @tar.tar_program = @@gtar }
178
- }
179
- assert_nothing_raised{ @tar.create('*.txt') }
180
- assert_raises(Tar::Error){ @tar.expand('blah.txt') }
181
-
182
- assert_nothing_raised{ @tar.extract_archive }
183
- assert_nothing_raised{ @tar.extract_archive('temp2.txt') }
184
- end
185
-
186
- def teardown
187
- @tar = nil
188
- File.delete('test.tar') if File.exists?('test.tar')
189
- File.delete('test.tar.gz') if File.exists?('test.tar.gz')
190
- File.delete('test.tar.bz2') if File.exists?('test.tar.bz2')
191
- File.delete('test.tar.zip') if File.exists?('test.tar.zip')
192
- end
193
-
194
- def self.shutdown
195
- @@tar_foudn = nil
196
- @@gzip_found = nil
197
- @@bzip2_found = nil
198
-
199
- File.delete(@@tmp_file1) if File.exists?(@@tmp_file1)
200
- File.delete(@@tmp_file2) if File.exists?(@@tmp_file2)
201
- File.delete(@@tmp_file3) if File.exists?(@@tmp_file3)
202
- end
203
- end