From 90dfc8f99e774e5ed71b4ed09a14bb75febca936 Mon Sep 17 00:00:00 2001 From: drbrain Date: Mon, 3 Oct 2011 22:15:47 +0000 Subject: * 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 --- lib/rubygems/commands/dependency_command.rb | 2 +- lib/rubygems/commands/query_command.rb | 2 +- lib/rubygems/dependency.rb | 2 +- lib/rubygems/dependency_list.rb | 2 +- lib/rubygems/deprecate.rb | 82 +++++++++++++++-------------- lib/rubygems/gem_path_searcher.rb | 2 +- lib/rubygems/indexer.rb | 2 +- lib/rubygems/platform.rb | 2 +- lib/rubygems/server.rb | 2 +- lib/rubygems/source_index.rb | 12 ++--- lib/rubygems/specification.rb | 4 +- 11 files changed, 58 insertions(+), 56 deletions(-) (limited to 'lib/rubygems') diff --git a/lib/rubygems/commands/dependency_command.rb b/lib/rubygems/commands/dependency_command.rb index f493d40289..67cbbc1d5e 100644 --- a/lib/rubygems/commands/dependency_command.rb +++ b/lib/rubygems/commands/dependency_command.rb @@ -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] diff --git a/lib/rubygems/commands/query_command.rb b/lib/rubygems/commands/query_command.rb index 1033b83447..725da8787b 100644 --- a/lib/rubygems/commands/query_command.rb +++ b/lib/rubygems/commands/query_command.rb @@ -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 diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb index 1e1663678e..0caf65c6c4 100644 --- a/lib/rubygems/dependency.rb +++ b/lib/rubygems/dependency.rb @@ -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 diff --git a/lib/rubygems/dependency_list.rb b/lib/rubygems/dependency_list.rb index d54b659b66..9f1da9166c 100644 --- a/lib/rubygems/dependency_list.rb +++ b/lib/rubygems/dependency_list.rb @@ -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 diff --git a/lib/rubygems/deprecate.rb b/lib/rubygems/deprecate.rb index 4827a05ad4..a78208ec24 100644 --- a/lib/rubygems/deprecate.rb +++ b/lib/rubygems/deprecate.rb @@ -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 - end + def self.skip # :nodoc: + @skip ||= false + end - def self.skip= v # :nodoc: - @skip = v - end + def self.skip= v # :nodoc: + @skip = v + end - ## - # Temporarily turn off warnings. Intended for tests only. + ## + # Temporarily turn off warnings. Intended for tests only. - def skip_during - Deprecate.skip, original = true, Deprecate.skip - yield - ensure - Deprecate.skip = original - end + 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. + ## + # 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 + 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 + module_function :deprecate, :skip_during + end end diff --git a/lib/rubygems/gem_path_searcher.rb b/lib/rubygems/gem_path_searcher.rb index 1d67d75149..814b5fb0e5 100644 --- a/lib/rubygems/gem_path_searcher.rb +++ b/lib/rubygems/gem_path_searcher.rb @@ -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 diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb index 23c0167be8..e87e5a3632 100644 --- a/lib/rubygems/indexer.rb +++ b/lib/rubygems/indexer.rb @@ -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| diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 4b5b6ef81a..4a4e3c1b35 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -186,7 +186,7 @@ class Gem::Platform CURRENT = 'current' - extend Deprecate + extend Gem::Deprecate deprecate :empty?, :none, 2011, 11 end diff --git a/lib/rubygems/server.rb b/lib/rubygems/server.rb index 9c49d1ff85..47fa7c562d 100644 --- a/lib/rubygems/server.rb +++ b/lib/rubygems/server.rb @@ -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 diff --git a/lib/rubygems/source_index.rb b/lib/rubygems/source_index.rb index 7ddbc23485..1fe92c0a80 100644 --- a/lib/rubygems/source_index.rb +++ b/lib/rubygems/source_index.rb @@ -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 diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 2059e0762d..97db19e69a 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -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 -- cgit v1.2.3