Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9343077
D2502.id8900.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D2502.id8900.diff
View Options
diff --git a/swh/indexer/metadata_dictionary/ruby.py b/swh/indexer/metadata_dictionary/ruby.py
--- a/swh/indexer/metadata_dictionary/ruby.py
+++ b/swh/indexer/metadata_dictionary/ruby.py
@@ -7,10 +7,17 @@
import itertools
import re
-from swh.indexer.codemeta import CROSSWALK_TABLE
+from swh.indexer.codemeta import CROSSWALK_TABLE, SCHEMA_URI
from .base import DictMapping
+def name_to_person(name):
+ return {
+ '@type': SCHEMA_URI + 'Person',
+ SCHEMA_URI + 'name': name,
+ }
+
+
class GemspecMapping(DictMapping):
name = 'gemspec'
mapping = CROSSWALK_TABLE['Ruby Gem']
@@ -109,9 +116,9 @@
def normalize_author(self, author):
if isinstance(author, str):
- return {"@list": [author]}
+ return {"@list": [name_to_person(author)]}
def normalize_authors(self, authors):
if isinstance(authors, list):
- return {"@list": [author for author in authors
+ return {"@list": [name_to_person(author) for author in authors
if isinstance(author, str)]}
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
@@ -213,7 +213,10 @@
'@context': 'https://doi.org/10.5063/schema/codemeta-2.0',
'name': 'test_metadata',
'version': '0.0.2',
- 'author': 'moranegg',
+ 'author': {
+ 'type': 'Person',
+ 'name': 'moranegg',
+ },
}]
# when
@@ -225,7 +228,10 @@
"version": '0.0.2',
"description": 'Simple package.json test for indexer',
"name": ['test_1', 'test_0_1', 'test_metadata'],
- "author": ['moranegg'],
+ "author": [{
+ 'type': 'Person',
+ 'name': 'moranegg'
+ }],
"codeRepository":
'git+https://github.com/moranegg/metadata_test',
}
@@ -1009,7 +1015,12 @@
self.assertEqual(result, {
'@context': 'https://doi.org/10.5063/schema/codemeta-2.0',
'type': 'SoftwareSourceCode',
- 'author': ['Ruby Coder'],
+ 'author': [
+ {
+ 'type': 'Person',
+ 'name': 'Ruby Coder'
+ }
+ ],
'name': 'example',
'license': 'https://spdx.org/licenses/MIT',
'codeRepository': 'https://rubygems.org/gems/example',
@@ -1025,7 +1036,15 @@
end"""
result = self.gemspec_mapping.translate(raw_content)
self.assertCountEqual(result.pop('author'), [
- 'Ruby Coder1', 'Ruby Coder2'])
+ {
+ 'type': 'Person',
+ 'name': 'Ruby Coder1'
+ },
+ {
+ 'type': 'Person',
+ 'name': 'Ruby Coder2'
+ },
+ ])
self.assertEqual(result, {
'@context': 'https://doi.org/10.5063/schema/codemeta-2.0',
'type': 'SoftwareSourceCode',
@@ -1058,7 +1077,12 @@
self.assertEqual(result, {
'@context': 'https://doi.org/10.5063/schema/codemeta-2.0',
'type': 'SoftwareSourceCode',
- 'author': ['Ruby Coder1'],
+ 'author': [
+ {
+ 'type': 'Person',
+ 'name': 'Ruby Coder1'
+ }
+ ],
})
def test_gemspec_alternative_header(self):
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 1:14 PM (1 w, 22 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3218519
Attached To
D2502: Fix type of 'author' in gemspec mapping output.
Event Timeline
Log In to Comment