summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosef Šimánek <josef.simanek@gmail.com>2020-04-19 17:43:31 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-08 07:38:50 +0900
commit856cbbdd52eaafd27c21a8f4dea7e89373667694 (patch)
treec9bb3c9574c83d53e3e0fdbbfe6e454e5f57235a /lib
parent4dd46dbad046c0c5902f0217243c3207dbb274b5 (diff)
[rubygems/rubygems] Track removed methods calls and warn during build time.
move rubyforge_project= to removed methods https://github.com/rubygems/rubygems/commit/223f7fd470
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3087
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/specification.rb20
-rw-r--r--lib/rubygems/specification_policy.rb10
2 files changed, 17 insertions, 13 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 6ff9a89699..eb622876fb 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -6,6 +6,7 @@
# See LICENSE.txt for permissions.
#++
+require 'set'
require 'rubygems/version'
require 'rubygems/requirement'
require 'rubygems/platform'
@@ -193,6 +194,12 @@ class Gem::Specification < Gem::BasicSpecification
@@spec_with_requirable_file = {}
@@active_stub_with_requirable_file = {}
+ # Tracking removed method calls to warn users during build time.
+ REMOVED_METHODS = [:rubyforge_project=].freeze # :nodoc:
+ def removed_method_calls
+ @removed_method_calls ||= Set.new
+ end
+
######################################################################
# :section: Required gemspec attributes
@@ -728,13 +735,6 @@ class Gem::Specification < Gem::BasicSpecification
attr_writer :original_platform # :nodoc:
##
- # Deprecated via specification policy and ignored during runtime.
- #
- # Formerly used to set rubyforge project.
-
- attr_accessor :rubyforge_project
-
- ##
# The Gem::Specification version of this gemspec.
#
# Do not set this, it is set automatically when the gem is packaged.
@@ -2099,9 +2099,15 @@ class Gem::Specification < Gem::BasicSpecification
end
##
+ # Track removed method calls to warn about during build time.
# Warn about unknown attributes while loading a spec.
def method_missing(sym, *a, &b) # :nodoc:
+ if REMOVED_METHODS.include?(sym)
+ removed_method_calls << sym
+ return
+ end
+
if @specification_version > CURRENT_SPECIFICATION_VERSION and
sym.to_s =~ /=$/
warn "ignoring #{sym} loading #{full_name}" if $DEBUG
diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb
index 8d4958c001..4b525df7d7 100644
--- a/lib/rubygems/specification_policy.rb
+++ b/lib/rubygems/specification_policy.rb
@@ -21,8 +21,6 @@ class Gem::SpecificationPolicy
funding_uri
].freeze # :nodoc:
- DEPRECATED_ATTRIBUTES = [:rubyforge_project].freeze #:nodoc:
-
def initialize(specification)
@warnings = 0
@@ -78,7 +76,7 @@ class Gem::SpecificationPolicy
validate_dependencies
- validate_deprecated_attributes
+ validate_removed_attributes
if @warnings > 0
if strict
@@ -413,9 +411,9 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li
warning "#{executable_path} is missing #! line"
end
- def validate_deprecated_attributes # :nodoc:
- DEPRECATED_ATTRIBUTES.each do |attr|
- warning("#{attr} is deprecated") unless @specification.send(attr).nil?
+ def validate_removed_attributes # :nodoc:
+ @specification.removed_method_calls.each do |attr|
+ warning("#{attr} is deprecated and ignored. Please remove this from your gemspec to ensure that your gem continues to build in the future.")
end
end