diff --git a/swh/indexer/metadata_dictionary.py b/swh/indexer/metadata_dictionary.py --- a/swh/indexer/metadata_dictionary.py +++ b/swh/indexer/metadata_dictionary.py @@ -534,7 +534,7 @@ name = 'gemspec' mapping = CROSSWALK_TABLE['Ruby Gem'] - _re_spec_new = re.compile(r'.*Gem::Specification.new do \|.*\|.*') + _re_spec_new = re.compile(r'.*Gem::Specification.new +(do|\{) +\|.*\|.*') _re_spec_entry = re.compile(r'\s*\w+\.(?P\w+)\s*=\s*(?P.*)') @classmethod diff --git a/swh/indexer/tests/test_metadata.py b/swh/indexer/tests/test_metadata.py --- a/swh/indexer/tests/test_metadata.py +++ b/swh/indexer/tests/test_metadata.py @@ -867,6 +867,23 @@ 'author': ['Ruby Coder1'], }) + def test_gemspec_alternative_header(self): + raw_content = b""" +require './lib/version' + +Gem::Specification.new { |s| + s.name = 'rb-system-with-aliases' + s.summary = 'execute system commands with aliases' +} +""" + result = self.gemspec_mapping.translate(raw_content) + self.assertEqual(result, { + '@context': 'https://doi.org/10.5063/schema/codemeta-2.0', + 'type': 'SoftwareSourceCode', + 'name': 'rb-system-with-aliases', + 'description': 'execute system commands with aliases', + }) + def test_revision_metadata_indexer(self): metadata_indexer = RevisionMetadataIndexer( config=REVISION_METADATA_CONFIG)