summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-11 10:24:01 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-07-31 07:47:02 +0800
commita2f0331c4e1c47425ec6042f41f4f4b1b63e557f (patch)
tree9b1509671f90fc553e9a9d8ec13c6ecc4661aaba
parent5947ea31ca7cd6a5aa7969088ef38ff9eb9be2da (diff)
[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
-rw-r--r--lib/rubygems/specification.rb14
-rw-r--r--test/rubygems/test_gem_specification.rb30
2 files changed, 14 insertions, 30 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 137cfbe13e..7e071623b0 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -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
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index 4d3fb93ff1..7577a3ca7d 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -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\"])