1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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

@ -1,3 +1,8 @@
Tue Oct 4 07:15:17 2011 Eric Hodel <drbrain@segment7.net>
* lib/rubygems: Update to RubyGems 1.8.11. Move Deprecate into the
Gem namespace.
Tue Oct 4 06:43:47 2011 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych.rb: update psych version.

View file

@ -118,7 +118,7 @@ require "rubygems/deprecate"
# -The RubyGems Team
module Gem
VERSION = '1.8.10'
VERSION = '1.8.11'
##
# Raised when RubyGems is unable to load or activate a gem. Contains the
@ -956,7 +956,7 @@ module Gem
# Returns the Gem::SourceIndex of specifications that are in the Gem.path
def self.source_index
@@source_index ||= Deprecate.skip_during do
@@source_index ||= Gem::Deprecate.skip_during do
SourceIndex.new Gem::Specification.dirs
end
end
@ -1262,7 +1262,7 @@ require 'rubygems/custom_require'
module Gem
class << self
extend Deprecate
extend Gem::Deprecate
deprecate :activate_dep, "Specification#activate", 2011, 6
deprecate :activate_spec, "Specification#activate", 2011, 6
deprecate :cache, "Gem::source_index", 2011, 8

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

View file

@ -435,7 +435,7 @@ class TestGem < Gem::TestCase
def test_self_available?
util_make_gems
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert(Gem.available?("a"))
assert(Gem.available?("a", "1"))
assert(Gem.available?("a", ">1"))
@ -937,7 +937,7 @@ class TestGem < Gem::TestCase
end
def test_self_source_index
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_kind_of Gem::SourceIndex, Gem.source_index
end
end
@ -1093,7 +1093,7 @@ class TestGem < Gem::TestCase
# @abin_path = File.join spec.full_gem_path, spec.bindir, 'abin'
# FileUtils.mkdir_p File.join(stem, "gems", "test-3")
Deprecate.skip_during do
Gem::Deprecate.skip_during do
expected = [File.join(@gemhome, "gems", "a-4", "lib")]
assert_equal expected, Gem.latest_load_paths
end

View file

@ -63,7 +63,7 @@ class TestGemDependency < Gem::TestCase
assert_match dep("a", ">= 0"), dep("a", "1"), "match version"
refute_match dep("a"), Object.new
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_match dep(/a/, ">= 0"), d, "match simple regexp"
assert_match dep(/a|b/, ">= 0"), d, "match scary regexp"
refute_match dep(/a/), dep("b")
@ -72,7 +72,7 @@ class TestGemDependency < Gem::TestCase
def test_equals_tilde_escape
refute_match dep("a|b"), dep("a", "1")
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_match dep(/a|b/), dep("a", "1")
end
end
@ -88,7 +88,7 @@ class TestGemDependency < Gem::TestCase
def test_equals_tilde_spec
assert_match dep("a", ">= 0"), spec("a", "0")
assert_match dep("a", "1"), spec("a", "1")
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_match dep(/a/, ">= 0"), spec("a", "0")
assert_match dep(/a|b/, ">= 0"), spec("b", "0")
refute_match dep(/a/, ">= 0"), spec("b", "0")

View file

@ -28,7 +28,7 @@ class TestGemDependencyList < Gem::TestCase
util_clear_gems
install_specs @a1, @b2
deps = Deprecate.skip_during { Gem::DependencyList.from_source_index }
deps = Gem::Deprecate.skip_during { Gem::DependencyList.from_source_index }
assert_equal %w[b-2 a-1], deps.dependency_order.map { |s| s.full_name }
end

View file

@ -29,23 +29,23 @@ class TestGemGemPathSearcher < Gem::TestCase
@fetcher = Gem::FakeFetcher.new
Gem::RemoteFetcher.fetcher = @fetcher
@gps = Deprecate.skip_during { Gem::GemPathSearcher.new }
@gps = Gem::Deprecate.skip_during { Gem::GemPathSearcher.new }
end
def test_find
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_equal @foo1, @gps.find('foo')
end
end
def test_find_all
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_equal [@foo1], @gps.find_all('foo')
end
end
def test_init_gemspecs
Deprecate.skip_during do
Gem::Deprecate.skip_during do
util_clear_gems
util_setup_spec_fetcher @foo1, @foo2, @bar1, @bar2
expected = [@bar2, @bar1, @foo2, @foo1].map(&:full_name)
@ -55,7 +55,7 @@ class TestGemGemPathSearcher < Gem::TestCase
end
def test_lib_dirs_for
Deprecate.skip_during do
Gem::Deprecate.skip_during do
lib_dirs = @gps.lib_dirs_for(@foo1)
expected = File.join @gemhome, 'gems', @foo1.full_name, '{lib,lib2}'
@ -64,20 +64,20 @@ class TestGemGemPathSearcher < Gem::TestCase
end
def test_lib_dirs_for_nil_require_paths
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_nil @gps.lib_dirs_for(@nrp)
end
end
def test_matching_file_eh
Deprecate.skip_during do
Gem::Deprecate.skip_during do
refute @gps.matching_file?(@foo1, 'bar')
assert @gps.matching_file?(@foo1, 'foo')
end
end
def test_matching_files
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_equal [], @gps.matching_files(@foo1, 'bar')
expected = File.join @foo1.full_gem_path, 'lib', 'foo.rb'
@ -87,7 +87,7 @@ class TestGemGemPathSearcher < Gem::TestCase
end
def test_matching_files_nil_require_paths
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_empty @gps.matching_files(@nrp, 'foo')
end
end

View file

@ -138,7 +138,7 @@ class TestGemPlatform < Gem::TestCase
def test_empty
platform = Gem::Platform.new 'cpu-other_platform1'
assert_respond_to platform, :empty?
assert_equal false, Deprecate.skip_during { platform.empty? }
assert_equal false, Gem::Deprecate.skip_during { platform.empty? }
end
def test_to_s

View file

@ -33,7 +33,7 @@ class TestGemServer < Gem::TestCase
data = StringIO.new "GET /Marshal.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
@req.parse data
Deprecate.skip_during do
Gem::Deprecate.skip_during do
@server.Marshal @req, @res
end
@ -41,7 +41,7 @@ class TestGemServer < Gem::TestCase
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
assert_equal 'application/octet-stream', @res['content-type']
Deprecate.skip_during do
Gem::Deprecate.skip_during do
si = Gem::SourceIndex.new
si.add_specs @a1, @a2
@ -53,7 +53,7 @@ class TestGemServer < Gem::TestCase
data = StringIO.new "GET /Marshal.#{Gem.marshal_version}.Z HTTP/1.0\r\n\r\n"
@req.parse data
Deprecate.skip_during do
Gem::Deprecate.skip_during do
@server.Marshal @req, @res
end
@ -61,7 +61,7 @@ class TestGemServer < Gem::TestCase
assert_match %r| \d\d:\d\d:\d\d |, @res['date']
assert_equal 'application/x-deflate', @res['content-type']
Deprecate.skip_during do
Gem::Deprecate.skip_during do
si = Gem::SourceIndex.new
si.add_specs @a1, @a2
@ -73,7 +73,7 @@ class TestGemServer < Gem::TestCase
data = StringIO.new "GET /latest_specs.#{Gem.marshal_version} HTTP/1.0\r\n\r\n"
@req.parse data
Deprecate.skip_during do
Gem::Deprecate.skip_during do
@server.latest_specs @req, @res
end
@ -88,7 +88,7 @@ class TestGemServer < Gem::TestCase
data = StringIO.new "GET /latest_specs.#{Gem.marshal_version}.gz HTTP/1.0\r\n\r\n"
@req.parse data
Deprecate.skip_during do
Gem::Deprecate.skip_during do
@server.latest_specs @req, @res
end

View file

@ -9,11 +9,11 @@ class TestGemSourceIndex < Gem::TestCase
util_setup_fake_fetcher
@source_index = Deprecate.skip_during { Gem.source_index }
@source_index = Gem::Deprecate.skip_during { Gem.source_index }
end
def test_find_name
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_equal [@a1, @a2, @a3a], @source_index.find_name('a')
assert_equal [@a2], @source_index.find_name('a', '= 2')
assert_equal [], @source_index.find_name('bogusstring')
@ -31,7 +31,7 @@ class TestGemSourceIndex < Gem::TestCase
end
def test_find_name_empty_cache
Deprecate.skip_during do
Gem::Deprecate.skip_during do
empty_source_index = Gem::SourceIndex.new
assert_equal [], empty_source_index.find_name("foo")
end
@ -39,7 +39,7 @@ class TestGemSourceIndex < Gem::TestCase
# HACK: deprecated impl is failing tests, but I may want to port it over
def test_latest_specs
Deprecate.skip_during do
Gem::Deprecate.skip_during do
p1_ruby = quick_spec 'p', '1'
p1_platform = quick_spec 'p', '1' do |spec|
spec.platform = Gem::Platform::CURRENT
@ -87,7 +87,7 @@ class TestGemSourceIndex < Gem::TestCase
end
def test_load_gems_in
Deprecate.skip_during do
Gem::Deprecate.skip_during do
spec_dir1 = File.join @gemhome, 'specifications'
spec_dir2 = File.join @tempdir, 'gemhome2', 'specifications'
@ -118,7 +118,7 @@ class TestGemSourceIndex < Gem::TestCase
# REFACTOR: move to test_gem_commands_outdated_command.rb
def test_outdated
Deprecate.skip_during do
Gem::Deprecate.skip_during do
util_setup_spec_fetcher
assert_equal [], @source_index.outdated
@ -139,7 +139,7 @@ class TestGemSourceIndex < Gem::TestCase
end
def test_prerelease_specs_kept_in_right_place
Deprecate.skip_during do
Gem::Deprecate.skip_during do
gem_a1_alpha = quick_spec 'abba', '1.a'
@source_index.add_spec gem_a1_alpha
@ -151,7 +151,7 @@ class TestGemSourceIndex < Gem::TestCase
end
def test_refresh_bang
Deprecate.skip_during do
Gem::Deprecate.skip_during do
a1_spec = File.join @gemhome, "specifications", @a1.spec_name
FileUtils.mv a1_spec, @tempdir
@ -171,7 +171,7 @@ class TestGemSourceIndex < Gem::TestCase
end
def test_remove_spec
Deprecate.skip_during do
Gem::Deprecate.skip_during do
si = Gem.source_index
expected = si.gems.keys.sort
@ -189,7 +189,7 @@ class TestGemSourceIndex < Gem::TestCase
end
def test_search
Deprecate.skip_during do
Gem::Deprecate.skip_during do
requirement = Gem::Requirement.create '= 9'
with_version = Gem::Dependency.new(/^a/, requirement)
assert_equal [@a_evil9], @source_index.search(with_version)
@ -203,7 +203,7 @@ class TestGemSourceIndex < Gem::TestCase
end
def test_search_platform
Deprecate.skip_during do
Gem::Deprecate.skip_during do
util_set_arch 'x86-my_platform1'
a1 = quick_spec 'a', '1'
@ -226,7 +226,7 @@ class TestGemSourceIndex < Gem::TestCase
end
def test_signature
Deprecate.skip_during do
Gem::Deprecate.skip_during do
sig = @source_index.gem_signature('foo-1.2.3')
assert_equal 64, sig.length
assert_match(/^[a-f0-9]{64}$/, sig)
@ -234,7 +234,7 @@ class TestGemSourceIndex < Gem::TestCase
end
def test_specification
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_equal @a1, @source_index.specification(@a1.full_name)
assert_nil @source_index.specification("foo-1.2.4")
@ -242,7 +242,7 @@ class TestGemSourceIndex < Gem::TestCase
end
def test_index_signature
Deprecate.skip_during do
Gem::Deprecate.skip_during do
sig = @source_index.index_signature
assert_match(/^[a-f0-9]{64}$/, sig)
end

View file

@ -222,7 +222,7 @@ bindir:
end
def test_self_load_legacy_ruby
spec = Deprecate.skip_during do
spec = Gem::Deprecate.skip_during do
eval LEGACY_RUBY_SPEC
end
assert_equal 'keyedlist', spec.name
@ -404,7 +404,7 @@ bindir:
assert @a2.activated?
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert @a2.loaded?
end
end
@ -677,7 +677,7 @@ bindir:
end
def test_installation_path
Deprecate.skip_during do
Gem::Deprecate.skip_during do
assert_equal @gemhome, @a1.installation_path
@a1.instance_variable_set :@loaded_from, nil
@ -977,7 +977,7 @@ end
end
def test_to_ruby_legacy
gemspec1 = Deprecate.skip_during do
gemspec1 = Gem::Deprecate.skip_during do
eval LEGACY_RUBY_SPEC
end
ruby_code = gemspec1.to_ruby