File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,6 +95,25 @@ def parse_node(base_indent)
9595
9696 if stripped . start_with? ( "- " ) || stripped == "-"
9797 parse_sequence ( indent , anchor )
98+ elsif stripped . start_with? ( "\" " ) && stripped . end_with? ( "\" " )
99+ # We don't need to care about the following case here:
100+ # 1. "value with comment" # ...
101+ # 2. "key": "value"
102+ #
103+ # 1. must not happen because YAMLSerializer doesn't emit any
104+ # comment. YAMLSerializer parses only YAML that is generated
105+ # by YAMLSerializer.
106+ #
107+ # 2. must not happen because #parse_node isn't used non
108+ # top-level mapping. Non top-level mapping always uses
109+ # #parse_mapping. Top-level mapping never use the '"key":
110+ # "value"' form because all top-level keys
111+ # ("!ruby/object:Gem::Specification"'s keys) are known and
112+ # #emit_specification doesn't quote anything.
113+ parse_plain_scalar ( indent , anchor )
114+ elsif stripped . start_with? ( "'" ) && stripped . end_with? ( "'" )
115+ # See also the above note for double quotation.
116+ parse_plain_scalar ( indent , anchor )
98117 elsif stripped =~ MAPPING_KEY_RE && !stripped . start_with? ( "!ruby/object:" )
99118 parse_mapping ( indent , anchor )
100119 elsif stripped . start_with? ( "!ruby/object:" )
Original file line number Diff line number Diff line change @@ -318,6 +318,20 @@ def test_requirements_hash_converted_to_array
318318 assert_kind_of Hash , reqs
319319 end
320320
321+ def test_requirement_quote
322+ yaml = <<~YAML
323+ requirements:
324+ - "system: arrow-glib>=25.0.0: amazon_linux: arrow-glib-devel"
325+ - 'system: arrow-glib>=25.0.0: fedora: libarrow-glib-devel'
326+ YAML
327+
328+ expected = [
329+ "system: arrow-glib>=25.0.0: amazon_linux: arrow-glib-devel" ,
330+ "system: arrow-glib>=25.0.0: fedora: libarrow-glib-devel" ,
331+ ]
332+ assert_equal expected , yaml_load ( yaml ) [ "requirements" ]
333+ end
334+
321335 def test_rdoc_options_hash_converted_to_array
322336 # Some gemspecs incorrectly have rdoc_options: {} instead of rdoc_options: []
323337 yaml = <<~YAML
You can’t perform that action at this time.
0 commit comments