swh.indexer.metadata_dictionary.ruby module#
- class swh.indexer.metadata_dictionary.ruby.GemspecMapping(log_suffix='')[source]#
Bases:
DictMapping
,SingleFileIntrinsicMapping
- name = 'gemspec'#
- mapping = {'author': rdflib.term.URIRef('http://schema.org/author'), 'authors': rdflib.term.URIRef('http://schema.org/author'), 'description': rdflib.term.URIRef('http://schema.org/description'), 'email': rdflib.term.URIRef('http://schema.org/email'), 'homepage': rdflib.term.URIRef('http://schema.org/codeRepository'), 'license': rdflib.term.URIRef('http://schema.org/license'), 'licenses': rdflib.term.URIRef('http://schema.org/license'), 'name': rdflib.term.URIRef('http://schema.org/name'), 'platform': rdflib.term.URIRef('http://schema.org/runtimePlatform'), 'summary': rdflib.term.URIRef('http://schema.org/description'), 'version': rdflib.term.URIRef('http://schema.org/version')}#
- string_fields: List[str] = ['name', 'version', 'description', 'summary', 'email']#
List of fields that are simple strings, and don’t need any normalization.
- uri_fields: List[str] = ['homepage']#
List of fields that are simple URIs, and don’t need any normalization.
- translate(raw_content)[source]#
Translates content by parsing content from a bytestring containing mapping-specific data and translating with the appropriate mapping to JSON-LD using the Codemeta and ForgeFed vocabularies.
- Parameters:
raw_content – raw content to translate
- Returns:
translated metadata in JSON friendly form needed for the content if parseable,
None
otherwise.
- eval_ruby_expression(expr)[source]#
Very simple evaluator of Ruby expressions.
>>> GemspecMapping().eval_ruby_expression('"Foo bar"') 'Foo bar' >>> GemspecMapping().eval_ruby_expression("'Foo bar'") 'Foo bar' >>> GemspecMapping().eval_ruby_expression("['Foo', 'bar']") ['Foo', 'bar'] >>> GemspecMapping().eval_ruby_expression("'Foo bar'.freeze") 'Foo bar' >>> GemspecMapping().eval_ruby_expression( "['Foo'.freeze, 'bar'.freeze]") ['Foo', 'bar']