diff options
Diffstat (limited to 'lib/rubygems/name_tuple.rb')
-rw-r--r-- | lib/rubygems/name_tuple.rb | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/rubygems/name_tuple.rb b/lib/rubygems/name_tuple.rb index c732d7f968..3f4a6fcf3d 100644 --- a/lib/rubygems/name_tuple.rb +++ b/lib/rubygems/name_tuple.rb @@ -1,18 +1,17 @@ # frozen_string_literal: true + ## # # Represents a gem of name +name+ at +version+ of +platform+. These # wrap the data returned from the indexes. class Gem::NameTuple - def initialize(name, version, platform="ruby") + def initialize(name, version, platform=Gem::Platform::RUBY) @name = name @version = version - unless platform.kind_of? Gem::Platform - platform = "ruby" if !platform or platform.empty? - end - + platform &&= platform.to_s + platform = Gem::Platform::RUBY if !platform || platform.empty? @platform = platform end @@ -31,7 +30,7 @@ class Gem::NameTuple # [name, version, platform] tuples. def self.to_basic(list) - list.map {|t| t.to_a } + list.map(&:to_a) end ## @@ -48,11 +47,11 @@ class Gem::NameTuple def full_name case @platform - when nil, 'ruby', '' + when nil, "", Gem::Platform::RUBY "#{@name}-#{@version}" else "#{@name}-#{@version}-#{@platform}" - end.dup.tap(&Gem::UNTAINT) + end end ## @@ -86,7 +85,7 @@ class Gem::NameTuple "#<Gem::NameTuple #{@name}, #{@version}, #{@platform}>" end - alias to_s inspect # :nodoc: + alias_method :to_s, :inspect # :nodoc: def <=>(other) [@name, @version, Gem::Platform.sort_priority(@platform)] <=> @@ -102,8 +101,8 @@ class Gem::NameTuple def ==(other) case other when self.class - @name == other.name and - @version == other.version and + @name == other.name && + @version == other.version && @platform == other.platform when Array to_a == other |