[rubygems/rubygems] Simplify #to_ruby code

Separate #add_runtime_dependency and #add_development_dependency
availability condition from #specification_version availability,
which is not related to directly.
Also check if the former method is available, instead of comparing
the version.

https://github.com/rubygems/rubygems/commit/5cccc2b836
This commit is contained in:
Nobuyoshi Nakada 2019-07-11 10:24:01 +09:00 коммит произвёл Hiroshi SHIBATA
Родитель 5947ea31ca
Коммит a2f0331c4e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F9CF13417264FAC2
2 изменённых файлов: 14 добавлений и 30 удалений

Просмотреть файл

@ -2476,25 +2476,17 @@ class Gem::Specification < Gem::BasicSpecification
result << nil
result << " if s.respond_to? :specification_version then"
result << " s.specification_version = #{specification_version}"
result << " end"
result << nil
result << " if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then"
result << " if s.respond_to? :add_runtime_dependency then"
dependencies.each do |dep|
req = dep.requirements_list.inspect
dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{req})"
result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>.freeze, #{req})"
end
result << " else"
dependencies.each do |dep|
version_reqs_param = dep.requirements_list.inspect
result << " s.add_dependency(%q<#{dep.name}>.freeze, #{version_reqs_param})"
end
result << ' end'
result << " else"
dependencies.each do |dep|
version_reqs_param = dep.requirements_list.inspect

Просмотреть файл

@ -2428,12 +2428,10 @@ Gem::Specification.new do |s|
if s.respond_to? :specification_version then
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION}
end
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<b>.freeze, [\"= 1\"])
else
s.add_dependency(%q<b>.freeze, [\"= 1\"])
end
if s.respond_to? :add_runtime_dependency then
s.add_runtime_dependency(%q<b>.freeze, [\"= 1\"])
else
s.add_dependency(%q<b>.freeze, [\"= 1\"])
end
@ -2478,12 +2476,10 @@ Gem::Specification.new do |s|
if s.respond_to? :specification_version then
s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION}
end
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<b>.freeze, [\"= 1\"])
else
s.add_dependency(%q<b>.freeze, [\"= 1\"])
end
if s.respond_to? :add_runtime_dependency then
s.add_runtime_dependency(%q<b>.freeze, [\"= 1\"])
else
s.add_dependency(%q<b>.freeze, [\"= 1\"])
end
@ -2539,16 +2535,12 @@ Gem::Specification.new do |s|
if s.respond_to? :specification_version then
s.specification_version = 4
end
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rake>.freeze, [\"> 0.4\"])
s.add_runtime_dependency(%q<jabber4r>.freeze, [\"> 0.0.0\"])
s.add_runtime_dependency(%q<pqa>.freeze, [\"> 0.4\", \"<= 0.6\"])
else
s.add_dependency(%q<rake>.freeze, [\"> 0.4\"])
s.add_dependency(%q<jabber4r>.freeze, [\"> 0.0.0\"])
s.add_dependency(%q<pqa>.freeze, [\"> 0.4\", \"<= 0.6\"])
end
if s.respond_to? :add_runtime_dependency then
s.add_runtime_dependency(%q<rake>.freeze, [\"> 0.4\"])
s.add_runtime_dependency(%q<jabber4r>.freeze, [\"> 0.0.0\"])
s.add_runtime_dependency(%q<pqa>.freeze, [\"> 0.4\", \"<= 0.6\"])
else
s.add_dependency(%q<rake>.freeze, [\"> 0.4\"])
s.add_dependency(%q<jabber4r>.freeze, [\"> 0.0.0\"])