Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an author - correct method? #18

Open
paulwalk opened this issue Apr 26, 2021 · 2 comments
Open

Adding an author - correct method? #18

paulwalk opened this issue Apr 26, 2021 · 2 comments

Comments

@paulwalk
Copy link

paulwalk commented Apr 26, 2021

Having played around with the API, I am able to add an author to an RO-Crate like this:

crate = ROCrate::Crate.new
crate.add_person('https://orcid.org/0000-0002-1825-0097', { name: 'Josiah Carberry' })
crate.metadata.properties['author'] = {'@id'=>'https://orcid.org/0000-0002-1825-0097'}

The README implies that there are shortcuts for common properties - it has an example using file.author where file is a data entity - but I don't think this method exists in the API.

I tried to logically reproduce this kind of approach by creating a variable for my person and then adding that:

crate = ROCrate::Crate.new
author = crate.add_person('https://orcid.org/0000-0002-1825-0097', { name: 'Josiah Carberry' })
crate.metadata.properties['author'] = author

but this does not work.

Is my first example the best approach to this? And is the README just a little out of date?

@fbacall
Copy link
Collaborator

fbacall commented Apr 26, 2021

You're right, that example in the README doesn't work. I think it's actually the code that is wrong though (there should be a convenience method for adding an author). I can't remember how I originally decided on which shortcut methods to include for each class, but I think it needs revisiting.

The equivalent "manual" way of doing what the author= method would do is this:

crate = ROCrate::Crate.new
author = crate.add_person('https://orcid.org/0000-0002-1825-0097', { name: 'Josiah Carberry' })
crate.metadata.properties['author'] = author.reference

and if you wanted to resolve it back to the Person object, you would do this:

author = crate.metadata.properties['author'].dereference

@paulwalk
Copy link
Author

Ah - I had missed the reference method - now the dereference method makes more sense to me!

Thanks :-)

fbacall added a commit that referenced this issue Apr 28, 2021
Updated README a bit, with note on property getting/setting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants