Use safe navigation operator.

This operator is available since Ruby 2.3 and we are not going to use
this generator with older Ruby.
This commit is contained in:
Vít Ondruch 2018-02-01 17:29:46 +01:00
parent b15350c441
commit 75ea12f0a3

View File

@ -44,7 +44,7 @@ module RubyGemsReq
def self.rubygems_dependency(specification) def self.rubygems_dependency(specification)
Helpers::requirement_versions_to_rpm(specification.required_rubygems_version).each do |requirement| Helpers::requirement_versions_to_rpm(specification.required_rubygems_version).each do |requirement|
dependency_string = "ruby(rubygems)" dependency_string = "ruby(rubygems)"
dependency_string += " #{specification.required_rubygems_version}" if requirement && requirement.length > 0 dependency_string += " #{specification.required_rubygems_version}" if requirement&.length > 0
puts dependency_string puts dependency_string
end end
end end
@ -54,7 +54,7 @@ module RubyGemsReq
specification.runtime_dependencies.each do |dependency| specification.runtime_dependencies.each do |dependency|
dependency_strings = Helpers::requirement_versions_to_rpm(dependency.requirement).map do |requirement| dependency_strings = Helpers::requirement_versions_to_rpm(dependency.requirement).map do |requirement|
requirement_string = "rubygem(#{dependency.name})" requirement_string = "rubygem(#{dependency.name})"
requirement_string += " #{requirement}" if requirement && requirement.length > 0 requirement_string += " #{requirement}" if requirement&.length > 0
requirement_string requirement_string
end end
dependency_string = dependency_strings.join(' with ') dependency_string = dependency_strings.join(' with ')