* lib/rubygems: Update to RubyGems 1.8.11. Move Deprecate into the

Gem namespace.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2011-10-03 22:15:47 +00:00
parent 9167328359
commit 90dfc8f99e
21 changed files with 112 additions and 105 deletions

View file

@ -59,7 +59,7 @@ class Gem::Commands::DependencyCommand < Gem::Command
end
# TODO: deprecate for real damnit
dependency = Deprecate.skip_during {
dependency = Gem::Deprecate.skip_during {
Gem::Dependency.new pattern, options[:version]
}
dependency.prerelease = options[:prerelease]

View file

@ -79,7 +79,7 @@ class Gem::Commands::QueryCommand < Gem::Command
req = Gem::Requirement.default
# TODO: deprecate for real
dep = Deprecate.skip_during { Gem::Dependency.new name, req }
dep = Gem::Deprecate.skip_during { Gem::Dependency.new name, req }
if local? then
if prerelease and not both? then

View file

@ -35,7 +35,7 @@ class Gem::Dependency
if Regexp === name then
msg = ["NOTE: Dependency.new w/ a regexp is deprecated.",
"Dependency.new called from #{Gem.location_of_caller.join(":")}"]
warn msg.join("\n") unless Deprecate.skip
warn msg.join("\n") unless Gem::Deprecate.skip
end
type = Symbol === requirements.last ? requirements.pop : :runtime

View file

@ -246,7 +246,7 @@ end
class Gem::DependencyList
class << self
extend Deprecate
extend Gem::Deprecate
deprecate :from_source_index, "from_specs", 2011, 11
end
end

View file

@ -11,58 +11,60 @@
# # ...
# end
#
# extend Deprecate
# extend Gem::Deprecate
# deprecate :instance_method, "X.z", 2011, 4
#
# class << self
# extend Deprecate
# extend Gem::Deprecate
# deprecate :klass_method, :none, 2011, 4
# end
# end
module Deprecate
module Gem
module Deprecate
def self.skip # :nodoc:
@skip ||= false
def self.skip # :nodoc:
@skip ||= false
end
def self.skip= v # :nodoc:
@skip = v
end
##
# Temporarily turn off warnings. Intended for tests only.
def skip_during
Gem::Deprecate.skip, original = true, Gem::Deprecate.skip
yield
ensure
Gem::Deprecate.skip = original
end
##
# Simple deprecation method that deprecates +name+ by wrapping it up
# in a dummy method. It warns on each call to the dummy method
# telling the user of +repl+ (unless +repl+ is :none) and the
# year/month that it is planned to go away.
def deprecate name, repl, year, month
class_eval {
old = "_deprecated_#{name}"
alias_method old, name
define_method name do |*args, &block| # TODO: really works on 1.8.7?
klass = self.kind_of? Module
target = klass ? "#{self}." : "#{self.class}#"
msg = [ "NOTE: #{target}#{name} is deprecated",
repl == :none ? " with no replacement" : ", use #{repl}",
". It will be removed on or after %4d-%02d-01." % [year, month],
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
]
warn "#{msg.join}." unless Gem::Deprecate.skip
send old, *args, &block
end
}
end
module_function :deprecate, :skip_during
end
def self.skip= v # :nodoc:
@skip = v
end
##
# Temporarily turn off warnings. Intended for tests only.
def skip_during
Deprecate.skip, original = true, Deprecate.skip
yield
ensure
Deprecate.skip = original
end
##
# Simple deprecation method that deprecates +name+ by wrapping it up
# in a dummy method. It warns on each call to the dummy method
# telling the user of +repl+ (unless +repl+ is :none) and the
# year/month that it is planned to go away.
def deprecate name, repl, year, month
class_eval {
old = "_deprecated_#{name}"
alias_method old, name
define_method name do |*args, &block| # TODO: really works on 1.8.7?
klass = self.kind_of? Module
target = klass ? "#{self}." : "#{self.class}#"
msg = [ "NOTE: #{target}#{name} is deprecated",
repl == :none ? " with no replacement" : ", use #{repl}",
". It will be removed on or after %4d-%02d-01." % [year, month],
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
]
warn "#{msg.join}." unless Deprecate.skip
send old, *args, &block
end
}
end
module_function :deprecate, :skip_during
end

View file

@ -160,7 +160,7 @@ class Gem::GemPathSearcher
spec.require_paths
end
extend Deprecate
extend Gem::Deprecate
deprecate :initialize, :none, 2011, 10
deprecate :find, :none, 2011, 10

View file

@ -377,7 +377,7 @@ class Gem::Indexer
# Collect specifications from .gem files from the gem directory.
def collect_specs(gems = gem_file_list)
Deprecate.skip_during do
Gem::Deprecate.skip_during do
index = Gem::SourceIndex.new
map_gems_to_specs(gems).each do |spec|

View file

@ -186,7 +186,7 @@ class Gem::Platform
CURRENT = 'current'
extend Deprecate
extend Gem::Deprecate
deprecate :empty?, :none, 2011, 11
end

View file

@ -462,7 +462,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
add_date res
index = Deprecate.skip_during { Marshal.dump Gem.source_index }
index = Gem::Deprecate.skip_during { Marshal.dump Gem.source_index }
if req.request_method == 'HEAD' then
res['content-length'] = index.length

View file

@ -72,7 +72,7 @@ class Gem::SourceIndex
# loaded spec.
def self.load_specification(file_name)
Deprecate.skip_during do
Gem::Deprecate.skip_during do
Gem::Specification.load Gem::Path.new(file_name)
end
end
@ -121,7 +121,7 @@ class Gem::SourceIndex
spec_files = Dir[File.join(spec_dir, "*.gemspec")]
spec_files.each do |spec_file|
gemspec = Deprecate.skip_during do
gemspec = Gem::Deprecate.skip_during do
Gem::Specification.load spec_file
end
add_spec gemspec if gemspec
@ -193,7 +193,7 @@ class Gem::SourceIndex
# Add gem specifications to the source index.
def add_specs(*gem_specs)
Deprecate.skip_during do
Gem::Deprecate.skip_during do
gem_specs.each do |spec|
add_spec spec
end
@ -251,7 +251,7 @@ class Gem::SourceIndex
def find_name(gem_name, requirement = Gem::Requirement.default)
dep = Gem::Dependency.new gem_name, requirement
Deprecate.skip_during do
Gem::Deprecate.skip_during do
search dep
end
end
@ -364,7 +364,7 @@ module Gem
end
class Gem::SourceIndex
extend Deprecate
extend Gem::Deprecate
deprecate :all_gems, :none, 2011, 10
@ -394,7 +394,7 @@ class Gem::SourceIndex
deprecate :specification, "Specification.find", 2011, 11
class << self
extend Deprecate
extend Gem::Deprecate
deprecate :from_gems_in, :none, 2011, 10
deprecate :from_installed_gems, :none, 2011, 10

View file

@ -329,7 +329,7 @@ class Gem::Specification
def self.all
warn "NOTE: Specification.all called from #{caller.first}" unless
Deprecate.skip
Gem::Deprecate.skip
_all
end
@ -2104,7 +2104,7 @@ class Gem::Specification
self.platform = Gem::Platform.new @platform
end
extend Deprecate
extend Gem::Deprecate
deprecate :test_suite_file, :test_file, 2011, 10
deprecate :test_suite_file=, :test_file=, 2011, 10