ruby-changes:61070
From: Josef <ko1@a...>
Date: Fri, 8 May 2020 07:39:40 +0900 (JST)
Subject: [ruby-changes:61070] 4dd46dbad0 (master): [rubygems/rubygems] Deprecate rubyforge_project attribute only during build time.
https://git.ruby-lang.org/ruby.git/commit/?id=4dd46dbad0 From 4dd46dbad046c0c5902f0217243c3207dbb274b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= <josef.simanek@g...> Date: Fri, 10 Apr 2020 18:58:04 +0200 Subject: [rubygems/rubygems] Deprecate rubyforge_project attribute only during build time. https://github.com/rubygems/rubygems/commit/c44eb21648 diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 18e3f2d..6ff9a89 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -728,12 +728,11 @@ class Gem::Specification < Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L728 attr_writer :original_platform # :nodoc: ## - # Deprecated and ignored. + # Deprecated via specification policy and ignored during runtime. # # Formerly used to set rubyforge project. - attr_writer :rubyforge_project - rubygems_deprecate :rubyforge_project= + attr_accessor :rubyforge_project ## # The Gem::Specification version of this gemspec. diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb index d9f415d..8d4958c 100644 --- a/lib/rubygems/specification_policy.rb +++ b/lib/rubygems/specification_policy.rb @@ -21,6 +21,8 @@ class Gem::SpecificationPolicy https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification_policy.rb#L21 funding_uri ].freeze # :nodoc: + DEPRECATED_ATTRIBUTES = [:rubyforge_project].freeze #:nodoc: + def initialize(specification) @warnings = 0 @@ -76,6 +78,8 @@ class Gem::SpecificationPolicy https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification_policy.rb#L78 validate_dependencies + validate_deprecated_attributes + if @warnings > 0 if strict error "specification has warnings" @@ -409,6 +413,12 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification_policy.rb#L413 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? + end + end + def warning(statement) # :nodoc: @warnings += 1 diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 1848e52..cf4a4de 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -3128,6 +3128,26 @@ http://spdx.org/licenses or 'Nonstandard' for a nonstandard license. https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L3128 warning end + def test_deprecated_attributes + assert_equal Gem::SpecificationPolicy::DEPRECATED_ATTRIBUTES, [:rubyforge_project] + end + + def test_validate_deprecated_attributes + util_setup_validate + + use_ui @ui do + Gem::SpecificationPolicy::DEPRECATED_ATTRIBUTES.each do |attr| + @a1.send("#{attr}=", 'invalid-attribute') + end + + @a1.validate + end + + Gem::SpecificationPolicy::DEPRECATED_ATTRIBUTES.each do |attr| + assert_match "#{attr} is deprecated", @ui.error + end + end + def test_validate_license_values util_setup_validate -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/