rubygems-update 0.9.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data/ChangeLog +135 -0
- data/Rakefile +3 -1
- data/lib/rubygems.rb +27 -38
- data/lib/rubygems/commands/install_command.rb +2 -0
- data/lib/rubygems/commands/mirror_command.rb +8 -2
- data/lib/rubygems/commands/query_command.rb +3 -1
- data/lib/rubygems/commands/server_command.rb +3 -3
- data/lib/rubygems/commands/unpack_command.rb +11 -4
- data/lib/rubygems/commands/update_command.rb +114 -108
- data/lib/rubygems/defaults.rb +46 -0
- data/lib/rubygems/dependency_installer.rb +13 -2
- data/lib/rubygems/indexer.rb +1 -1
- data/lib/rubygems/install_update_options.rb +7 -0
- data/lib/rubygems/installer.rb +66 -11
- data/lib/rubygems/package.rb +2 -1
- data/lib/rubygems/platform.rb +24 -30
- data/lib/rubygems/remote_fetcher.rb +7 -3
- data/lib/rubygems/require_paths_builder.rb +15 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +1 -1
- data/lib/rubygems/server.rb +18 -3
- data/lib/rubygems/source_index.rb +20 -23
- data/lib/rubygems/source_info_cache.rb +3 -3
- data/lib/rubygems/specification.rb +64 -31
- data/lib/rubygems/uninstaller.rb +1 -1
- data/lib/rubygems/validator.rb +3 -2
- data/lib/rubygems/version.rb +10 -3
- data/setup.rb +30 -6
- data/test/gemutilities.rb +23 -13
- data/test/gemutilities.rbc +0 -0
- data/test/mockgemui.rbc +0 -0
- data/test/test_gem.rb +46 -76
- data/test/test_gem.rbc +0 -0
- data/test/test_gem_commands_build_command.rb +12 -12
- data/test/test_gem_commands_dependency_command.rb +10 -10
- data/test/test_gem_commands_mirror_command.rb +9 -4
- data/test/test_gem_commands_query_command.rb +7 -3
- data/test/test_gem_commands_server_command.rb +27 -0
- data/test/test_gem_commands_unpack_command.rb +20 -2
- data/test/test_gem_format.rb +1 -1
- data/test/test_gem_indexer.rb +5 -5
- data/test/test_gem_install_update_options.rb +1 -1
- data/test/test_gem_installer.rb +149 -60
- data/test/test_gem_platform.rb +19 -0
- data/test/test_gem_remote_fetcher.rb +19 -2
- data/test/test_gem_server.rb +44 -1
- data/test/test_gem_source_index.rb +2 -2
- data/test/test_gem_specification.rb +300 -168
- data/test/test_gem_version.rb +15 -0
- data/test/test_kernel.rb +19 -19
- metadata +46 -42
- data/lib/rubygems/remote_installer.rb +0 -195
- data/test/test_gem_remote_installer.rb +0 -161
data/lib/rubygems/server.rb
CHANGED
@@ -368,19 +368,34 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
|
368
368
|
when '/quick/index.rz' then
|
369
369
|
index = @source_index.map { |name,_| name }.join("\n")
|
370
370
|
res.body << Zlib::Deflate.deflate(index)
|
371
|
-
when %r|^/quick/(
|
372
|
-
|
371
|
+
when %r|^/quick/(Marshal.#{Regexp.escape Gem.marshal_version}/)?(.*?)-([0-9.]+)(-.*?)?\.gemspec\.rz$| then
|
372
|
+
dep = Gem::Dependency.new $2, $3
|
373
|
+
specs = @source_index.search dep
|
374
|
+
|
375
|
+
selector = [$2, $3, $4].map { |s| s.inspect }.join ' '
|
376
|
+
|
377
|
+
platform = if $4 then
|
378
|
+
Gem::Platform.new $4.sub(/^-/, '')
|
379
|
+
else
|
380
|
+
Gem::Platform::RUBY
|
381
|
+
end
|
382
|
+
|
383
|
+
specs = specs.select { |s| s.platform == platform }
|
384
|
+
|
373
385
|
if specs.empty? then
|
374
386
|
res.status = 404
|
387
|
+
res.body = "No gems found matching #{selector}"
|
375
388
|
elsif specs.length > 1 then
|
376
389
|
res.status = 500
|
377
|
-
|
390
|
+
res.body = "Multiple gems found matching #{selector}"
|
391
|
+
elsif $1 then # marshal quickindex instead of YAML
|
378
392
|
res.body << Zlib::Deflate.deflate(Marshal.dump(specs.first))
|
379
393
|
else # deprecated YAML format
|
380
394
|
res.body << Zlib::Deflate.deflate(specs.first.to_yaml)
|
381
395
|
end
|
382
396
|
else
|
383
397
|
res.status = 404
|
398
|
+
res.body = "#{req.request_uri} not found"
|
384
399
|
end
|
385
400
|
end
|
386
401
|
|
@@ -4,8 +4,6 @@
|
|
4
4
|
# See LICENSE.txt for permissions.
|
5
5
|
#++
|
6
6
|
|
7
|
-
require 'forwardable'
|
8
|
-
|
9
7
|
require 'rubygems'
|
10
8
|
require 'rubygems/user_interaction'
|
11
9
|
require 'rubygems/specification'
|
@@ -23,7 +21,6 @@ module Gem
|
|
23
21
|
# YAMLized source index objects to load properly.
|
24
22
|
#
|
25
23
|
class SourceIndex
|
26
|
-
extend Forwardable
|
27
24
|
|
28
25
|
include Enumerable
|
29
26
|
|
@@ -186,40 +183,40 @@ module Gem
|
|
186
183
|
Gem::SHA256.new.hexdigest(@gems[gem_full_name].to_yaml).to_s
|
187
184
|
end
|
188
185
|
|
189
|
-
|
186
|
+
def size
|
187
|
+
@gems.size
|
188
|
+
end
|
189
|
+
alias length size
|
190
190
|
|
191
191
|
# Find a gem by an exact match on the short name.
|
192
192
|
def find_name(gem_name, version_requirement = Gem::Requirement.default)
|
193
193
|
search(/^#{gem_name}$/, version_requirement)
|
194
194
|
end
|
195
195
|
|
196
|
-
# Search for a gem by
|
197
|
-
#
|
198
|
-
#
|
199
|
-
# [String] a partial for the (short) name of the gem, or
|
200
|
-
# [Regex] a pattern to match against the short name
|
201
|
-
# version_requirement::
|
202
|
-
# [String | default=Gem::Requirement.default] version to
|
203
|
-
# find
|
204
|
-
# return::
|
205
|
-
# [Array] list of Gem::Specification objects in sorted (version)
|
206
|
-
# order. Empty if not found.
|
196
|
+
# Search for a gem by Gem::Dependency +gem_pattern+. If +only_platform+
|
197
|
+
# is true, only gems matching Gem::Platform.local will be returned. An
|
198
|
+
# Array of matching Gem::Specification objects is returned.
|
207
199
|
#
|
208
|
-
|
200
|
+
# For backwards compatibility, a String or Regexp pattern may be passed as
|
201
|
+
# +gem_pattern+, and a Gem::Requirement for +platform_only+. This
|
202
|
+
# behavior is deprecated and will be removed.
|
203
|
+
def search(gem_pattern, platform_only = false)
|
209
204
|
version_requirement = nil
|
210
205
|
only_platform = false
|
211
206
|
|
212
|
-
case gem_pattern
|
207
|
+
case gem_pattern # TODO warn after 2008/03, remove three months after
|
213
208
|
when Regexp then
|
214
|
-
version_requirement =
|
215
|
-
Gem::Requirement.default
|
209
|
+
version_requirement = platform_only || Gem::Requirement.default
|
216
210
|
when Gem::Dependency then
|
217
|
-
only_platform =
|
211
|
+
only_platform = platform_only
|
218
212
|
version_requirement = gem_pattern.version_requirements
|
219
|
-
gem_pattern = gem_pattern.name.empty?
|
213
|
+
gem_pattern = if gem_pattern.name.empty? then
|
214
|
+
//
|
215
|
+
else
|
216
|
+
/^#{Regexp.escape gem_pattern.name}$/
|
217
|
+
end
|
220
218
|
else
|
221
|
-
version_requirement =
|
222
|
-
Gem::Requirement.default
|
219
|
+
version_requirement = platform_only || Gem::Requirement.default
|
223
220
|
gem_pattern = /#{gem_pattern}/i
|
224
221
|
end
|
225
222
|
|
@@ -176,7 +176,7 @@ class Gem::SourceInfoCache
|
|
176
176
|
|
177
177
|
# The name of the system cache file. (class method)
|
178
178
|
def self.system_cache_file
|
179
|
-
@system_cache_file ||=
|
179
|
+
@system_cache_file ||= Gem.default_system_source_cache_dir
|
180
180
|
end
|
181
181
|
|
182
182
|
# The name of the user cache file.
|
@@ -187,7 +187,7 @@ class Gem::SourceInfoCache
|
|
187
187
|
# The name of the user cache file. (class method)
|
188
188
|
def self.user_cache_file
|
189
189
|
@user_cache_file ||=
|
190
|
-
ENV['GEMCACHE'] ||
|
190
|
+
ENV['GEMCACHE'] || Gem.default_user_source_cache_dir
|
191
191
|
end
|
192
192
|
|
193
193
|
# Write data to the proper cache.
|
@@ -217,7 +217,7 @@ class Gem::SourceInfoCache
|
|
217
217
|
unless File.exist? dir then
|
218
218
|
begin
|
219
219
|
FileUtils.mkdir_p(dir)
|
220
|
-
rescue RuntimeError
|
220
|
+
rescue RuntimeError, SystemCallError
|
221
221
|
return nil
|
222
222
|
end
|
223
223
|
end
|
@@ -4,17 +4,18 @@
|
|
4
4
|
# See LICENSE.txt for permissions.
|
5
5
|
#++
|
6
6
|
|
7
|
-
require 'time'
|
8
7
|
require 'rubygems'
|
9
8
|
require 'rubygems/version'
|
10
9
|
require 'rubygems/platform'
|
11
10
|
|
12
11
|
# :stopdoc:
|
13
12
|
# Time::today has been deprecated in 0.9.5 and will be removed.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
if RUBY_VERSION < '1.9' then
|
14
|
+
def Time.today
|
15
|
+
t = Time.now
|
16
|
+
t - ((t.to_i + t.gmt_offset) % 86400)
|
17
|
+
end unless defined? Time.today
|
18
|
+
end
|
18
19
|
# :startdoc:
|
19
20
|
|
20
21
|
module Gem
|
@@ -239,7 +240,7 @@ module Gem
|
|
239
240
|
@specification_version,
|
240
241
|
@name,
|
241
242
|
@version,
|
242
|
-
(Time === @date ? @date : Time.parse(@date.to_s)),
|
243
|
+
(Time === @date ? @date : (require 'time'; Time.parse(@date.to_s))),
|
243
244
|
@summary,
|
244
245
|
@required_ruby_version,
|
245
246
|
@required_rubygems_version,
|
@@ -293,14 +294,9 @@ module Gem
|
|
293
294
|
spec
|
294
295
|
end
|
295
296
|
|
296
|
-
def warn_deprecated(old, new)
|
297
|
-
# How (if at all) to implement this? We only want to warn when
|
298
|
-
# a gem is being built, I should think.
|
299
|
-
end
|
300
|
-
|
301
297
|
# REQUIRED gemspec attributes ------------------------------------
|
302
298
|
|
303
|
-
required_attribute :rubygems_version, RubyGemsVersion
|
299
|
+
required_attribute :rubygems_version, Gem::RubyGemsVersion
|
304
300
|
required_attribute :specification_version, CURRENT_SPECIFICATION_VERSION
|
305
301
|
required_attribute :name
|
306
302
|
required_attribute :version
|
@@ -349,12 +345,12 @@ module Gem
|
|
349
345
|
# DEPRECATED gemspec attributes ----------------------------------
|
350
346
|
|
351
347
|
def test_suite_file
|
352
|
-
|
348
|
+
warn 'test_suite_file deprecated, use test_files'
|
353
349
|
test_files.first
|
354
350
|
end
|
355
351
|
|
356
352
|
def test_suite_file=(val)
|
357
|
-
|
353
|
+
warn 'test_suite_file= deprecated, use test_files='
|
358
354
|
@test_files = [] unless defined? @test_files
|
359
355
|
@test_files << val
|
360
356
|
end
|
@@ -386,6 +382,7 @@ module Gem
|
|
386
382
|
case platform
|
387
383
|
when Gem::Platform::CURRENT then
|
388
384
|
@new_platform = Gem::Platform.local
|
385
|
+
@original_platform = @new_platform.to_s
|
389
386
|
|
390
387
|
when Gem::Platform then
|
391
388
|
@new_platform = platform
|
@@ -393,14 +390,14 @@ module Gem
|
|
393
390
|
# legacy constants
|
394
391
|
when nil, Gem::Platform::RUBY then
|
395
392
|
@new_platform = Gem::Platform::RUBY
|
396
|
-
when Gem::Platform::WIN32
|
397
|
-
@new_platform = Gem::Platform
|
398
|
-
when Gem::Platform::LINUX_586
|
399
|
-
@new_platform = Gem::Platform
|
400
|
-
when Gem::Platform::DARWIN
|
401
|
-
@new_platform = Gem::Platform
|
393
|
+
when 'mswin32' then # was Gem::Platform::WIN32
|
394
|
+
@new_platform = Gem::Platform.new 'x86-mswin32'
|
395
|
+
when 'i586-linux' then # was Gem::Platform::LINUX_586
|
396
|
+
@new_platform = Gem::Platform.new 'x86-linux'
|
397
|
+
when 'powerpc-darwin' then # was Gem::Platform::DARWIN
|
398
|
+
@new_platform = Gem::Platform.new 'ppc-darwin'
|
402
399
|
else
|
403
|
-
@new_platform = platform
|
400
|
+
@new_platform = Gem::Platform.new platform
|
404
401
|
end
|
405
402
|
|
406
403
|
@platform = @new_platform.to_s
|
@@ -422,11 +419,16 @@ module Gem
|
|
422
419
|
# way to do it.
|
423
420
|
case date
|
424
421
|
when String then
|
425
|
-
@date =
|
422
|
+
@date = if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
|
423
|
+
Time.local($1.to_i, $2.to_i, $3.to_i)
|
424
|
+
else
|
425
|
+
require 'time'
|
426
|
+
Time.parse date
|
427
|
+
end
|
426
428
|
when Time then
|
427
|
-
@date = Time.
|
429
|
+
@date = Time.local(date.year, date.month, date.day)
|
428
430
|
when Date then
|
429
|
-
@date = Time.
|
431
|
+
@date = Time.local(date.year, date.month, date.day)
|
430
432
|
else
|
431
433
|
@date = TODAY
|
432
434
|
end
|
@@ -751,7 +753,10 @@ module Gem
|
|
751
753
|
out.map taguri, to_yaml_style do |map|
|
752
754
|
map.add 'name', @name
|
753
755
|
map.add 'version', @version
|
754
|
-
platform =
|
756
|
+
platform = case @original_platform
|
757
|
+
when nil, '' then
|
758
|
+
'ruby'
|
759
|
+
when String then
|
755
760
|
@original_platform
|
756
761
|
else
|
757
762
|
@original_platform.to_s
|
@@ -801,13 +806,14 @@ module Gem
|
|
801
806
|
:version,
|
802
807
|
]
|
803
808
|
|
804
|
-
attributes = @@attributes.sort_by { |
|
809
|
+
attributes = @@attributes.sort_by { |attr_name,| attr_name.to_s }
|
805
810
|
|
806
|
-
attributes.each do |
|
807
|
-
next if handled.include?
|
808
|
-
current_value = self.send(
|
809
|
-
if current_value != default or
|
810
|
-
|
811
|
+
attributes.each do |attr_name, default|
|
812
|
+
next if handled.include? attr_name
|
813
|
+
current_value = self.send(attr_name)
|
814
|
+
if current_value != default or
|
815
|
+
self.class.required_attribute? attr_name then
|
816
|
+
result << " s.#{attr_name} = #{ruby_code current_value}"
|
811
817
|
end
|
812
818
|
end
|
813
819
|
|
@@ -832,6 +838,8 @@ module Gem
|
|
832
838
|
# Raises InvalidSpecificationException if the spec does not pass
|
833
839
|
# the checks..
|
834
840
|
def validate
|
841
|
+
extend Gem::UserInteraction
|
842
|
+
|
835
843
|
normalize
|
836
844
|
|
837
845
|
if rubygems_version != RubyGemsVersion then
|
@@ -858,6 +866,31 @@ module Gem
|
|
858
866
|
"invalid platform #{platform.inspect}, see Gem::Platform"
|
859
867
|
end
|
860
868
|
|
869
|
+
unless Array === authors and
|
870
|
+
authors.all? { |author| String === author } then
|
871
|
+
raise Gem::InvalidSpecificationException,
|
872
|
+
'authors must be Array of Strings'
|
873
|
+
end
|
874
|
+
|
875
|
+
# Warnings
|
876
|
+
|
877
|
+
%w[author email homepage rubyforge_project summary].each do |attribute|
|
878
|
+
value = self.send attribute
|
879
|
+
alert_warning "no #{attribute} specified" if value.nil? or value.empty?
|
880
|
+
end
|
881
|
+
|
882
|
+
alert_warning "RDoc will not be generated (has_rdoc == false)" unless
|
883
|
+
has_rdoc
|
884
|
+
|
885
|
+
alert_warning "deprecated autorequire specified" if autorequire
|
886
|
+
|
887
|
+
executables.each do |executable|
|
888
|
+
executable_path = File.join bindir, executable
|
889
|
+
shebang = File.read(executable_path, 2) == '#!'
|
890
|
+
|
891
|
+
alert_warning "#{executable_path} is missing #! line" unless shebang
|
892
|
+
end
|
893
|
+
|
861
894
|
true
|
862
895
|
end
|
863
896
|
|
data/lib/rubygems/uninstaller.rb
CHANGED
@@ -144,7 +144,7 @@ class Gem::Uninstaller
|
|
144
144
|
cache_dir = File.join spec.installation_path, 'cache'
|
145
145
|
gem = File.join cache_dir, "#{spec.full_name}.gem"
|
146
146
|
|
147
|
-
unless File.exist?
|
147
|
+
unless File.exist? gem then
|
148
148
|
gem = File.join cache_dir, "#{original_platform_name}.gem"
|
149
149
|
end
|
150
150
|
|
data/lib/rubygems/validator.rb
CHANGED
@@ -157,8 +157,9 @@ module Gem
|
|
157
157
|
# XXX: why do we need this gem_spec when we've already got 'spec'?
|
158
158
|
test_files = gem_spec.test_files
|
159
159
|
if test_files.empty?
|
160
|
-
say "There are no unit tests to run for #{gem_spec.
|
161
|
-
|
160
|
+
say "There are no unit tests to run for #{gem_spec.full_name}"
|
161
|
+
require 'test/unit/ui/console/testrunner'
|
162
|
+
return Test::Unit::TestResult.new
|
162
163
|
end
|
163
164
|
gem gem_spec.name, "= #{gem_spec.version.version}"
|
164
165
|
test_files.each do |f| require f end
|
data/lib/rubygems/version.rb
CHANGED
@@ -75,7 +75,7 @@ class Gem::Version
|
|
75
75
|
|
76
76
|
# Strip ignored trailing zeros.
|
77
77
|
def normalize
|
78
|
-
@ints =
|
78
|
+
@ints = build_array_from_version_string
|
79
79
|
|
80
80
|
return if @ints.length == 1
|
81
81
|
|
@@ -127,19 +127,26 @@ class Gem::Version
|
|
127
127
|
@ints <=> other.ints
|
128
128
|
end
|
129
129
|
|
130
|
-
|
130
|
+
alias eql? == # :nodoc:
|
131
|
+
|
132
|
+
def hash # :nodoc:
|
131
133
|
to_ints.inject { |hash_code, n| hash_code + n }
|
132
134
|
end
|
133
135
|
|
134
136
|
# Return a new version object where the next to the last revision
|
135
137
|
# number is one greater. (e.g. 5.3.1 => 5.4)
|
136
138
|
def bump
|
137
|
-
ints =
|
139
|
+
ints = build_array_from_version_string
|
138
140
|
ints.pop if ints.size > 1
|
139
141
|
ints[-1] += 1
|
140
142
|
self.class.new(ints.join("."))
|
141
143
|
end
|
142
144
|
|
145
|
+
def build_array_from_version_string
|
146
|
+
@version.to_s.scan(/\d+/).map { |s| s.to_i }
|
147
|
+
end
|
148
|
+
private :build_array_from_version_string
|
149
|
+
|
143
150
|
#:stopdoc:
|
144
151
|
|
145
152
|
require 'rubygems/requirement'
|
data/setup.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
#++
|
7
7
|
|
8
8
|
# Make sure rubygems isn't already loaded.
|
9
|
-
if ENV['RUBYOPT']
|
9
|
+
if ENV['RUBYOPT'] and defined? Gem then
|
10
10
|
ENV.delete 'RUBYOPT'
|
11
11
|
|
12
12
|
ruby = File.join Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']
|
@@ -18,6 +18,22 @@ end
|
|
18
18
|
$:.unshift 'lib'
|
19
19
|
require 'rubygems'
|
20
20
|
|
21
|
+
if ARGV.include? '--help' then
|
22
|
+
puts "ruby setup.rb [options]:"
|
23
|
+
puts
|
24
|
+
puts " --prefix=DIR Prefix path for installing RubyGems"
|
25
|
+
puts " Will not affect gem repository"
|
26
|
+
puts
|
27
|
+
puts " --format-executable Make the gem command's prefix and suffix match ruby's"
|
28
|
+
puts " If ruby is installed as ruby19, gem will be gem19"
|
29
|
+
puts
|
30
|
+
puts " --no-rdoc Don't build RDoc for RubyGems"
|
31
|
+
puts
|
32
|
+
puts " --no-ri Don't build ri for RubyGems"
|
33
|
+
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
|
21
37
|
require 'fileutils'
|
22
38
|
require 'rbconfig'
|
23
39
|
require 'rdoc/rdoc'
|
@@ -44,14 +60,16 @@ if ARGV.grep(/^--prefix/).empty? then
|
|
44
60
|
else
|
45
61
|
prefix = nil
|
46
62
|
|
47
|
-
ARGV.grep(/^--prefix
|
48
|
-
if
|
63
|
+
prefix_arg = ARGV.grep(/^--prefix=/).first
|
64
|
+
if prefix_arg =~ /^--prefix=(.*)/ then
|
65
|
+
prefix = $1
|
66
|
+
else
|
49
67
|
path_index = ARGV.index '--prefix'
|
50
68
|
prefix = ARGV[path_index + 1]
|
51
|
-
else
|
52
|
-
prefix = $1
|
53
69
|
end
|
54
70
|
|
71
|
+
prefix = File.expand_path prefix
|
72
|
+
|
55
73
|
raise "invalid --prefix #{prefix.inspect}" if prefix.nil?
|
56
74
|
|
57
75
|
lib_dir = File.join prefix, 'lib'
|
@@ -77,7 +95,13 @@ Dir.chdir 'bin' do
|
|
77
95
|
bin_files = Dir['*']
|
78
96
|
|
79
97
|
bin_files.each do |bin_file|
|
80
|
-
|
98
|
+
bin_file_formatted = if ARGV.include? '--format-executable' then
|
99
|
+
bin_file
|
100
|
+
else
|
101
|
+
Gem.default_exec_format % bin_file
|
102
|
+
end
|
103
|
+
|
104
|
+
dest_file = File.join bin_dir, bin_file_formatted
|
81
105
|
bin_tmp_file = File.join Dir.tmpdir, bin_file
|
82
106
|
|
83
107
|
begin
|