Productivity
This repository has been developed as part of the FAIR4CoreEOSC project to address two project's pillars (Describe and Cite).
[!Note] A demonstrable version can be accessed here: Demo Version
Sample snapshot of the codemeta generator and converter demo:
It currently addresses metadata conversions for the following use cases:
From | To |
---|---|
CodeMeta | DataCite 1 |
CodeMeta | BibLatex 2 |
CodeMeta | BibTex 3 |
The codemeta conversion pattern to the above schemes is extendable to other metadata schemes as template classes located under Schemes
directory. The initial keys correspondence is defined in this repository 4.
[!Note] There's a scheme template class that can help see this pattern. Please consult the crosswalk 4 and scheme documentations to properly construct this class.
1) Clone this project.
2) Open a console session and navigate to the cloned directory:
Run "composer install"
This should involve installing the PHP REPL, PsySH
3) (optional) Add psysh to PATH
Example, Bash:
echo 'export PATH="$PATH:/The_Cloned_Directory/vendor/bin"' >> ~/.bashrc
source ~/.bashrc
4) (Optional) Create your local branch.
$ psysh // if not added to PATH replace with: vendor/bin/psysh
Psy Shell v0.12.0 (PHP 8.2.0 — cli) by Justin Hileman
> namespace Conversions;
> use Conversions;
> $codeMetaPath = 'CodeMeta/codeMeta.json'
[!Note] By default, codemeta.json is located under 'CodeMeta' directory where an example already exists.
$codeMetaPath
can also directly take codemeta.json as an array
> $dataCite = \Schemes\DataCite::class
> $bibLatex = \Schemes\BibLatex::class
> $bibTex = \Schemes\BibTex::class
[!Note] By default, scheme classes are located under 'Schemes' directory.
> $errors = NULL; // initialise errors variable
> $dataCiteFromCodeMeta = CodeMetaConversion::To($dataCite, $codeMetaPath, $errors) // array-formatted
> $bibLatexFromCodeMeta = CodeMetaConversion::To($bibLatex, $codeMetaPath, $errors) // string-formatted
> $bibTexFromCodeMeta = CodeMetaConversion::To($bibTex, $codeMetaPath, $errors) // string-formatted
Illuminate\Support\MessageBag()
instance:> $errors->messages() // gets error messages as specified in CodeMeta/conversionsValidations.php
> $errors->keys() // gets codemeta keys where errors occurred
> $errors->first() // gets the first occurred error message
> $errors->has('identifier') // checks whether an error has occurred in the codemeta `identifier` key
[!Note] Validations use the
Illuminate\Validation\Validator
package. Error messages and rules can be customised inCodeMeta/conversionsValidations.php
as per the package syntax.