swh.indexer.metadata_dictionary.ruby module

swh.indexer.metadata_dictionary.ruby.name_to_person(name)[source]
class swh.indexer.metadata_dictionary.ruby.GemspecMapping(log_suffix='')[source]

Bases: swh.indexer.metadata_dictionary.base.DictMapping

name = 'gemspec'
mapping = {'author': 'http://schema.org/author', 'authors': 'http://schema.org/author', 'description': 'http://schema.org/description', 'email': 'http://schema.org/email', 'homepage': 'http://schema.org/codeRepository', 'license': 'http://schema.org/license', 'licenses': 'http://schema.org/license', 'name': 'http://schema.org/name', 'platform': 'http://schema.org/runtimePlatform', 'summary': 'http://schema.org/description', 'version': 'http://schema.org/version'}
string_fields = ['name', 'version', 'description', 'summary', 'email']
classmethod detect_metadata_files(file_entries)[source]

Detects files potentially containing metadata

Parameters

file_entries (list) – list of files

Returns

list of sha1 (possibly empty)

Return type

list

translate(raw_content)[source]
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']
normalize_homepage(s)[source]
normalize_license(s)[source]
normalize_licenses(licenses)[source]
normalize_author(author)[source]
normalize_authors(authors)[source]