rubygems-update 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +24 -0
- data/.document +4 -3
- data/ChangeLog +382 -1
- data/Manifest.txt +214 -0
- data/README +1 -49
- data/Rakefile +124 -191
- data/bin/gem +1 -4
- data/cruise_config.rb +22 -0
- data/doc/release_notes/rel_1_3_1.rdoc +3 -3
- data/doc/release_notes/rel_1_3_2.rdoc +119 -0
- data/lib/gauntlet_rubygems.rb +50 -0
- data/lib/rubygems.rb +250 -25
- data/lib/rubygems/builder.rb +62 -60
- data/lib/rubygems/command.rb +421 -319
- data/lib/rubygems/command_manager.rb +153 -125
- data/lib/rubygems/commands/check_command.rb +12 -7
- data/lib/rubygems/commands/cleanup_command.rb +11 -2
- data/lib/rubygems/commands/contents_command.rb +42 -18
- data/lib/rubygems/commands/generate_index_command.rb +91 -15
- data/lib/rubygems/commands/install_command.rb +33 -47
- data/lib/rubygems/commands/query_command.rb +36 -20
- data/lib/rubygems/commands/rdoc_command.rb +62 -68
- data/lib/rubygems/commands/search_command.rb +26 -32
- data/lib/rubygems/commands/setup_command.rb +353 -0
- data/lib/rubygems/commands/sources_command.rb +5 -0
- data/lib/rubygems/commands/specification_command.rb +23 -3
- data/lib/rubygems/commands/uninstall_command.rb +71 -61
- data/lib/rubygems/commands/unpack_command.rb +14 -12
- data/lib/rubygems/commands/update_command.rb +26 -5
- data/lib/rubygems/defaults.rb +16 -3
- data/lib/rubygems/dependency.rb +38 -7
- data/lib/rubygems/dependency_installer.rb +7 -4
- data/lib/rubygems/digest/digest_adapter.rb +42 -33
- data/lib/rubygems/digest/sha1.rb +6 -1
- data/lib/rubygems/digest/sha2.rb +5 -0
- data/lib/rubygems/doc_manager.rb +31 -11
- data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
- data/lib/rubygems/ext/rake_builder.rb +6 -2
- data/lib/rubygems/format.rb +63 -63
- data/lib/rubygems/gem_openssl.rb +14 -2
- data/lib/rubygems/gem_path_searcher.rb +7 -3
- data/lib/rubygems/gem_runner.rb +59 -39
- data/lib/rubygems/indexer.rb +450 -109
- data/lib/rubygems/install_update_options.rb +13 -1
- data/lib/rubygems/installer.rb +25 -22
- data/lib/rubygems/local_remote_options.rb +5 -3
- data/lib/rubygems/old_format.rb +124 -120
- data/lib/rubygems/package/tar_header.rb +25 -3
- data/lib/rubygems/package/tar_input.rb +5 -5
- data/lib/rubygems/package/tar_output.rb +2 -0
- data/lib/rubygems/package/tar_reader.rb +19 -0
- data/lib/rubygems/package/tar_reader/entry.rb +43 -0
- data/lib/rubygems/package/tar_writer.rb +65 -3
- data/lib/rubygems/package_task.rb +117 -0
- data/lib/rubygems/platform.rb +12 -8
- data/lib/rubygems/remote_fetcher.rb +43 -24
- data/lib/rubygems/require_paths_builder.rb +14 -12
- data/lib/rubygems/requirement.rb +15 -6
- data/lib/rubygems/rubygems_version.rb +14 -1
- data/lib/rubygems/source_index.rb +38 -16
- data/lib/rubygems/source_info_cache_entry.rb +2 -2
- data/lib/rubygems/spec_fetcher.rb +43 -20
- data/lib/rubygems/specification.rb +1122 -947
- data/lib/rubygems/text.rb +30 -0
- data/lib/rubygems/timer.rb +14 -11
- data/lib/rubygems/uninstaller.rb +25 -5
- data/lib/rubygems/user_interaction.rb +294 -264
- data/lib/rubygems/validator.rb +70 -36
- data/lib/rubygems/version.rb +97 -33
- data/lib/rubygems/version_option.rb +1 -0
- data/setup.rb +11 -306
- data/test/foo/discover.rb +0 -0
- data/test/gem_installer_test_case.rb +22 -11
- data/test/gem_package_tar_test_case.rb +0 -14
- data/test/gemutilities.rb +89 -8
- data/test/mockgemui.rb +2 -1
- data/test/rubygems_plugin.rb +16 -0
- data/test/test_gem.rb +107 -36
- data/test/test_gem_command.rb +3 -13
- data/test/test_gem_command_manager.rb +1 -14
- data/test/test_gem_commands_cert_command.rb +1 -1
- data/test/test_gem_commands_contents_command.rb +63 -0
- data/test/test_gem_commands_environment_command.rb +1 -1
- data/test/test_gem_commands_generate_index_command.rb +104 -1
- data/test/test_gem_commands_install_command.rb +95 -0
- data/test/test_gem_commands_pristine_command.rb +3 -3
- data/test/test_gem_commands_query_command.rb +46 -0
- data/test/test_gem_commands_sources_command.rb +9 -5
- data/test/test_gem_commands_specification_command.rb +31 -0
- data/test/test_gem_commands_uninstall_command.rb +3 -2
- data/test/test_gem_commands_unpack_command.rb +3 -2
- data/test/test_gem_commands_update_command.rb +12 -7
- data/test/test_gem_dependency.rb +62 -11
- data/test/test_gem_dependency_installer.rb +18 -5
- data/test/test_gem_dependency_list.rb +6 -6
- data/test/test_gem_doc_manager.rb +7 -1
- data/test/test_gem_ext_configure_builder.rb +8 -10
- data/test/test_gem_ext_ext_conf_builder.rb +14 -8
- data/test/test_gem_gem_path_searcher.rb +1 -1
- data/test/test_gem_gem_runner.rb +11 -0
- data/test/test_gem_indexer.rb +398 -21
- data/test/test_gem_install_update_options.rb +20 -6
- data/test/test_gem_installer.rb +22 -14
- data/test/test_gem_local_remote_options.rb +2 -1
- data/test/test_gem_package_tar_header.rb +3 -3
- data/test/test_gem_package_tar_input.rb +3 -3
- data/test/test_gem_package_tar_output.rb +2 -2
- data/test/test_gem_package_task.rb +70 -0
- data/test/test_gem_platform.rb +12 -6
- data/test/test_gem_remote_fetcher.rb +23 -1
- data/test/test_gem_source_index.rb +32 -21
- data/test/test_gem_spec_fetcher.rb +77 -5
- data/test/test_gem_specification.rb +274 -1
- data/test/test_gem_uninstaller.rb +34 -4
- data/test/test_gem_version.rb +94 -4
- data/test/test_gem_version_option.rb +13 -0
- data/test/test_kernel.rb +4 -4
- data/util/CL2notes +56 -0
- data/util/gem_prelude.rb.template +251 -0
- metadata +30 -20
- metadata.gz.sig +3 -4
- data/TODO +0 -1
- data/scripts/buildtests.rb +0 -31
- data/scripts/gemdoc.rb +0 -67
- data/scripts/runtest.rb +0 -40
- data/scripts/specdoc.rb +0 -171
- data/scripts/upload_gemdoc.rb +0 -140
@@ -72,9 +72,9 @@ class Gem::Package::TarInput
|
|
72
72
|
# map trust policy from string to actual class (or a serialized YAML
|
73
73
|
# file, if that exists)
|
74
74
|
if String === security_policy then
|
75
|
-
if Gem::Security::
|
75
|
+
if Gem::Security::Policies.key? security_policy then
|
76
76
|
# load one of the pre-defined security policies
|
77
|
-
security_policy = Gem::Security::
|
77
|
+
security_policy = Gem::Security::Policies[security_policy]
|
78
78
|
elsif File.exist? security_policy then
|
79
79
|
# FIXME: this doesn't work yet
|
80
80
|
security_policy = YAML.load File.read(security_policy)
|
@@ -136,10 +136,10 @@ class Gem::Package::TarInput
|
|
136
136
|
|
137
137
|
def extract_entry(destdir, entry, expected_md5sum = nil)
|
138
138
|
if entry.directory? then
|
139
|
-
dest = File.join
|
139
|
+
dest = File.join destdir, entry.full_name
|
140
140
|
|
141
|
-
if File.
|
142
|
-
@fileops.chmod entry.header.mode, dest, :verbose=>false
|
141
|
+
if File.directory? dest then
|
142
|
+
@fileops.chmod entry.header.mode, dest, :verbose => false
|
143
143
|
else
|
144
144
|
@fileops.mkdir_p dest, :mode => entry.header.mode, :verbose => false
|
145
145
|
end
|
@@ -66,8 +66,10 @@ class Gem::Package::TarOutput
|
|
66
66
|
Zlib::GzipWriter.wrap(sio || inner) do |os|
|
67
67
|
|
68
68
|
Gem::Package::TarWriter.new os do |data_tar_writer|
|
69
|
+
# :stopdoc:
|
69
70
|
def data_tar_writer.metadata() @metadata end
|
70
71
|
def data_tar_writer.metadata=(metadata) @metadata = metadata end
|
72
|
+
# :startdoc:
|
71
73
|
|
72
74
|
yield data_tar_writer
|
73
75
|
|
@@ -5,12 +5,21 @@
|
|
5
5
|
|
6
6
|
require 'rubygems/package'
|
7
7
|
|
8
|
+
##
|
9
|
+
# TarReader reads tar files and allows iteration over their items
|
10
|
+
|
8
11
|
class Gem::Package::TarReader
|
9
12
|
|
10
13
|
include Gem::Package
|
11
14
|
|
15
|
+
##
|
16
|
+
# Raised if the tar IO is not seekable
|
17
|
+
|
12
18
|
class UnexpectedEOF < StandardError; end
|
13
19
|
|
20
|
+
##
|
21
|
+
# Creates a new TarReader on +io+ and yields it to the block, if given.
|
22
|
+
|
14
23
|
def self.new(io)
|
15
24
|
reader = super
|
16
25
|
|
@@ -25,14 +34,24 @@ class Gem::Package::TarReader
|
|
25
34
|
nil
|
26
35
|
end
|
27
36
|
|
37
|
+
##
|
38
|
+
# Creates a new tar file reader on +io+ which needs to respond to #pos,
|
39
|
+
# #eof?, #read, #getc and #pos=
|
40
|
+
|
28
41
|
def initialize(io)
|
29
42
|
@io = io
|
30
43
|
@init_pos = io.pos
|
31
44
|
end
|
32
45
|
|
46
|
+
##
|
47
|
+
# Close the tar file
|
48
|
+
|
33
49
|
def close
|
34
50
|
end
|
35
51
|
|
52
|
+
##
|
53
|
+
# Iterates over files in the tarball yielding each entry
|
54
|
+
|
36
55
|
def each
|
37
56
|
loop do
|
38
57
|
return if @io.eof?
|
@@ -5,10 +5,19 @@
|
|
5
5
|
|
6
6
|
require 'rubygems/package'
|
7
7
|
|
8
|
+
##
|
9
|
+
# Class for reading entries out of a tar file
|
10
|
+
|
8
11
|
class Gem::Package::TarReader::Entry
|
9
12
|
|
13
|
+
##
|
14
|
+
# Header for this tar entry
|
15
|
+
|
10
16
|
attr_reader :header
|
11
17
|
|
18
|
+
##
|
19
|
+
# Creates a new tar entry for +header+ that will be read from +io+
|
20
|
+
|
12
21
|
def initialize(header, io)
|
13
22
|
@closed = false
|
14
23
|
@header = header
|
@@ -21,24 +30,39 @@ class Gem::Package::TarReader::Entry
|
|
21
30
|
raise IOError, "closed #{self.class}" if closed?
|
22
31
|
end
|
23
32
|
|
33
|
+
##
|
34
|
+
# Number of bytes read out of the tar entry
|
35
|
+
|
24
36
|
def bytes_read
|
25
37
|
@read
|
26
38
|
end
|
27
39
|
|
40
|
+
##
|
41
|
+
# Closes the tar entry
|
42
|
+
|
28
43
|
def close
|
29
44
|
@closed = true
|
30
45
|
end
|
31
46
|
|
47
|
+
##
|
48
|
+
# Is the tar entry closed?
|
49
|
+
|
32
50
|
def closed?
|
33
51
|
@closed
|
34
52
|
end
|
35
53
|
|
54
|
+
##
|
55
|
+
# Are we at the end of the tar entry?
|
56
|
+
|
36
57
|
def eof?
|
37
58
|
check_closed
|
38
59
|
|
39
60
|
@read >= @header.size
|
40
61
|
end
|
41
62
|
|
63
|
+
##
|
64
|
+
# Full name of the tar entry
|
65
|
+
|
42
66
|
def full_name
|
43
67
|
if @header.prefix != "" then
|
44
68
|
File.join @header.prefix, @header.name
|
@@ -47,6 +71,9 @@ class Gem::Package::TarReader::Entry
|
|
47
71
|
end
|
48
72
|
end
|
49
73
|
|
74
|
+
##
|
75
|
+
# Read one byte from the tar entry
|
76
|
+
|
50
77
|
def getc
|
51
78
|
check_closed
|
52
79
|
|
@@ -58,20 +85,33 @@ class Gem::Package::TarReader::Entry
|
|
58
85
|
ret
|
59
86
|
end
|
60
87
|
|
88
|
+
##
|
89
|
+
# Is this tar entry a directory?
|
90
|
+
|
61
91
|
def directory?
|
62
92
|
@header.typeflag == "5"
|
63
93
|
end
|
64
94
|
|
95
|
+
##
|
96
|
+
# Is this tar entry a file?
|
97
|
+
|
65
98
|
def file?
|
66
99
|
@header.typeflag == "0"
|
67
100
|
end
|
68
101
|
|
102
|
+
##
|
103
|
+
# The position in the tar entry
|
104
|
+
|
69
105
|
def pos
|
70
106
|
check_closed
|
71
107
|
|
72
108
|
bytes_read
|
73
109
|
end
|
74
110
|
|
111
|
+
##
|
112
|
+
# Reads +len+ bytes from the tar file entry, or the rest of the entry if
|
113
|
+
# nil
|
114
|
+
|
75
115
|
def read(len = nil)
|
76
116
|
check_closed
|
77
117
|
|
@@ -86,6 +126,9 @@ class Gem::Package::TarReader::Entry
|
|
86
126
|
ret
|
87
127
|
end
|
88
128
|
|
129
|
+
##
|
130
|
+
# Rewinds to the beginning of the tar file entry
|
131
|
+
|
89
132
|
def rewind
|
90
133
|
check_closed
|
91
134
|
|
@@ -5,13 +5,30 @@
|
|
5
5
|
|
6
6
|
require 'rubygems/package'
|
7
7
|
|
8
|
+
##
|
9
|
+
# Allows writing of tar files
|
10
|
+
|
8
11
|
class Gem::Package::TarWriter
|
9
12
|
|
10
13
|
class FileOverflow < StandardError; end
|
11
14
|
|
15
|
+
##
|
16
|
+
# IO wrapper that allows writing a limited amount of data
|
17
|
+
|
12
18
|
class BoundedStream
|
13
19
|
|
14
|
-
|
20
|
+
##
|
21
|
+
# Maximum number of bytes that can be written
|
22
|
+
|
23
|
+
attr_reader :limit
|
24
|
+
|
25
|
+
##
|
26
|
+
# Number of bytes written
|
27
|
+
|
28
|
+
attr_reader :written
|
29
|
+
|
30
|
+
##
|
31
|
+
# Wraps +io+ and allows up to +limit+ bytes to be written
|
15
32
|
|
16
33
|
def initialize(io, limit)
|
17
34
|
@io = io
|
@@ -19,6 +36,10 @@ class Gem::Package::TarWriter
|
|
19
36
|
@written = 0
|
20
37
|
end
|
21
38
|
|
39
|
+
##
|
40
|
+
# Writes +data+ onto the IO, raising a FileOverflow exception if the
|
41
|
+
# number of bytes will be more than #limit
|
42
|
+
|
22
43
|
def write(data)
|
23
44
|
if data.size + @written > @limit
|
24
45
|
raise FileOverflow, "You tried to feed more data than fits in the file."
|
@@ -30,18 +51,30 @@ class Gem::Package::TarWriter
|
|
30
51
|
|
31
52
|
end
|
32
53
|
|
54
|
+
##
|
55
|
+
# IO wrapper that provides only #write
|
56
|
+
|
33
57
|
class RestrictedStream
|
34
58
|
|
59
|
+
##
|
60
|
+
# Creates a new RestrictedStream wrapping +io+
|
61
|
+
|
35
62
|
def initialize(io)
|
36
63
|
@io = io
|
37
64
|
end
|
38
65
|
|
66
|
+
##
|
67
|
+
# Writes +data+ onto the IO
|
68
|
+
|
39
69
|
def write(data)
|
40
70
|
@io.write data
|
41
71
|
end
|
42
72
|
|
43
73
|
end
|
44
74
|
|
75
|
+
##
|
76
|
+
# Creates a new TarWriter, yielding it if a block is given
|
77
|
+
|
45
78
|
def self.new(io)
|
46
79
|
writer = super
|
47
80
|
|
@@ -56,12 +89,19 @@ class Gem::Package::TarWriter
|
|
56
89
|
nil
|
57
90
|
end
|
58
91
|
|
92
|
+
##
|
93
|
+
# Creates a new TarWriter that will write to +io+
|
94
|
+
|
59
95
|
def initialize(io)
|
60
96
|
@io = io
|
61
97
|
@closed = false
|
62
98
|
end
|
63
99
|
|
64
|
-
|
100
|
+
##
|
101
|
+
# Adds file +name+ with permissions +mode+, and yields an IO for writing the
|
102
|
+
# file to
|
103
|
+
|
104
|
+
def add_file(name, mode) # :yields: io
|
65
105
|
check_closed
|
66
106
|
|
67
107
|
raise Gem::Package::NonSeekableIO unless @io.respond_to? :pos=
|
@@ -90,7 +130,11 @@ class Gem::Package::TarWriter
|
|
90
130
|
self
|
91
131
|
end
|
92
132
|
|
93
|
-
|
133
|
+
##
|
134
|
+
# Add file +name+ with permissions +mode+ +size+ bytes long. Yields an IO
|
135
|
+
# to write the file to.
|
136
|
+
|
137
|
+
def add_file_simple(name, mode, size) # :yields: io
|
94
138
|
check_closed
|
95
139
|
|
96
140
|
name, prefix = split_name name
|
@@ -112,10 +156,16 @@ class Gem::Package::TarWriter
|
|
112
156
|
self
|
113
157
|
end
|
114
158
|
|
159
|
+
##
|
160
|
+
# Raises IOError if the TarWriter is closed
|
161
|
+
|
115
162
|
def check_closed
|
116
163
|
raise IOError, "closed #{self.class}" if closed?
|
117
164
|
end
|
118
165
|
|
166
|
+
##
|
167
|
+
# Closes the TarWriter
|
168
|
+
|
119
169
|
def close
|
120
170
|
check_closed
|
121
171
|
|
@@ -125,16 +175,25 @@ class Gem::Package::TarWriter
|
|
125
175
|
@closed = true
|
126
176
|
end
|
127
177
|
|
178
|
+
##
|
179
|
+
# Is the TarWriter closed?
|
180
|
+
|
128
181
|
def closed?
|
129
182
|
@closed
|
130
183
|
end
|
131
184
|
|
185
|
+
##
|
186
|
+
# Flushes the TarWriter's IO
|
187
|
+
|
132
188
|
def flush
|
133
189
|
check_closed
|
134
190
|
|
135
191
|
@io.flush if @io.respond_to? :flush
|
136
192
|
end
|
137
193
|
|
194
|
+
##
|
195
|
+
# Creates a new directory in the tar file +name+ with +mode+
|
196
|
+
|
138
197
|
def mkdir(name, mode)
|
139
198
|
check_closed
|
140
199
|
|
@@ -149,6 +208,9 @@ class Gem::Package::TarWriter
|
|
149
208
|
self
|
150
209
|
end
|
151
210
|
|
211
|
+
##
|
212
|
+
# Splits +name+ into a name and prefix that can fit in the TarHeader
|
213
|
+
|
152
214
|
def split_name(name) # :nodoc:
|
153
215
|
raise Gem::Package::TooLongFileName if name.size > 256
|
154
216
|
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# Copyright (c) 2003, 2004 Jim Weirich, 2009 Eric Hodel
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
begin
|
24
|
+
gem 'rake'
|
25
|
+
rescue Gem::LoadError
|
26
|
+
end
|
27
|
+
|
28
|
+
require 'rake/packagetask'
|
29
|
+
|
30
|
+
##
|
31
|
+
# Create a package based upon a Gem::Specification. Gem packages, as well as
|
32
|
+
# zip files and tar/gzipped packages can be produced by this task.
|
33
|
+
#
|
34
|
+
# In addition to the Rake targets generated by Gem::PackageTask, a
|
35
|
+
# Gem::GemPackageTask will also generate the following tasks:
|
36
|
+
#
|
37
|
+
# [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.gem"</b>]
|
38
|
+
# Create a RubyGems package with the given name and version.
|
39
|
+
#
|
40
|
+
# Example using a Gem::Specification:
|
41
|
+
#
|
42
|
+
# require 'rubygems'
|
43
|
+
#
|
44
|
+
# spec = Gem::Specification.new do |s|
|
45
|
+
# s.platform = Gem::Platform::RUBY
|
46
|
+
# s.summary = "Ruby based make-like utility."
|
47
|
+
# s.name = 'rake'
|
48
|
+
# s.version = PKG_VERSION
|
49
|
+
# s.requirements << 'none'
|
50
|
+
# s.require_path = 'lib'
|
51
|
+
# s.autorequire = 'rake'
|
52
|
+
# s.files = PKG_FILES
|
53
|
+
# s.description = <<-EOF
|
54
|
+
# Rake is a Make-like program implemented in Ruby. Tasks
|
55
|
+
# and dependencies are specified in standard Ruby syntax.
|
56
|
+
# EOF
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# Gem::PackageTask.new(spec) do |pkg|
|
60
|
+
# pkg.need_zip = true
|
61
|
+
# pkg.need_tar = true
|
62
|
+
# end
|
63
|
+
|
64
|
+
class Gem::PackageTask < Rake::PackageTask
|
65
|
+
|
66
|
+
##
|
67
|
+
# Ruby Gem::Specification containing the metadata for this package. The
|
68
|
+
# name, version and package_files are automatically determined from the
|
69
|
+
# gemspec and don't need to be explicitly provided.
|
70
|
+
|
71
|
+
attr_accessor :gem_spec
|
72
|
+
|
73
|
+
##
|
74
|
+
# Create a Gem Package task library. Automatically define the gem if a
|
75
|
+
# block is given. If no block is supplied, then #define needs to be called
|
76
|
+
# to define the task.
|
77
|
+
|
78
|
+
def initialize(gem_spec)
|
79
|
+
init(gem_spec)
|
80
|
+
yield self if block_given?
|
81
|
+
define if block_given?
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Initialization tasks without the "yield self" or define operations.
|
86
|
+
|
87
|
+
def init(gem)
|
88
|
+
super(gem.name, gem.version)
|
89
|
+
@gem_spec = gem
|
90
|
+
@package_files += gem_spec.files if gem_spec.files
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# Create the Rake tasks and actions specified by this Gem::PackageTask.
|
95
|
+
# (+define+ is automatically called if a block is given to +new+).
|
96
|
+
|
97
|
+
def define
|
98
|
+
super
|
99
|
+
task :package => [:gem]
|
100
|
+
desc "Build the gem file #{gem_file}"
|
101
|
+
task :gem => ["#{package_dir}/#{gem_file}"]
|
102
|
+
file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do
|
103
|
+
when_writing("Creating #{gem_spec.full_name}.gem") {
|
104
|
+
Gem::Builder.new(gem_spec).build
|
105
|
+
verbose(true) {
|
106
|
+
mv gem_file, "#{package_dir}/#{gem_file}"
|
107
|
+
}
|
108
|
+
}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def gem_file
|
113
|
+
"#{@gem_spec.full_name}.gem"
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|