Skip to content

Commit cf566c3

Browse files
committed
Construct Gem::Platform from cpu/os/version fields
1 parent cbe57bb commit cf566c3

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

lib/rubygems/yaml_serializer.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,7 @@ def build_version(node)
484484

485485
def build_platform(node)
486486
hash = pairs_to_hash(node)
487-
if hash["value"]
488-
Gem::Platform.new(hash["value"])
489-
else
490-
Gem::Platform.new([hash["cpu"], hash["os"], hash["version"]])
491-
end
487+
Gem::Platform.new([hash["cpu"], hash["os"], hash["version"]])
492488
end
493489

494490
def build_requirement(node)

test/rubygems/test_gem_safe_yaml.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -933,14 +933,7 @@ def test_load_platform_from_value_field
933933
yaml = "!ruby/object:Gem::Platform\nvalue: x86-linux\n"
934934
plat = yaml_load(yaml, permitted_classes: Gem::SafeYAML::PERMITTED_CLASSES)
935935
assert_kind_of Gem::Platform, plat
936-
if Gem.use_psych?
937-
# Psych doesn't interpret the "value" field specially
938-
assert_nil plat.cpu
939-
else
940-
# YAMLSerializer parses the "value" field as a platform string
941-
assert_equal "x86", plat.cpu
942-
assert_equal "linux", plat.os
943-
end
936+
assert_nil plat.cpu
944937
end
945938

946939
def test_load_platform_from_cpu_os_version_fields

0 commit comments

Comments
 (0)