|
class ZenodoFileExport |
|
# +export_type+ represents the kind of file this is. Must be set in |
|
# a subclass (or NotImplementedError will be raised). |
|
# |
|
# It is also used to determine the relationships between this and other |
|
# ZenodoFileExports. |
|
# |
|
# * the first report of its kind will become the parent DOI for all the ones that follow |
|
# * the latest uploaded report of its kind will become the newer version of the previous report |
|
# * the previously uploaded report of its kind will become marked as a previous version of the latest |
|
# |
|
cattr_accessor :export_type |
|
|
|
# If not supplied then there would be no README added to the uploaded Zenodo deposition. |
|
# THIS WOULD ONLY EXIST IF YOU WANTED A README TO BE A PROMINENT PART OF A ZENODO EXPORT. |
|
# OTHERWISE, the readme_file would just be added as another generic file to the export. |
|
cattr_accessor :readme_file |
|
|
|
def export! |
|
# Default implementation for Zenodo file exports |
|
# * look for the earliest Zenodo file export that has this export_type |
|
# * If found, use that as the parent DOI for the IsPartOf relation |
|
# * If not found, do not set the parent DOI for IsPartOf, as this will be the parent |
|
# * look for the previous Zenodo file export that has the same export_type |
|
# * If found, use that as the DOI for the IsNewerVersionOf relation. |
|
# * If not found, do not set the IsNewerVersionOf relation |
|
# * after export to Zenodo, if we had a previous version then update it to set its IsPreviousOf relation to this DOI |
|
# |
|
end |
|
end |
|
|
|
|
|
################################### USAGE EXAMPLE |
|
|
|
# with prominent readme |
|
export_1 = ZenodoFileExport.new( |
|
files: ["path/to/alm_report.zip"], |
|
export_type: "AlmStatsZenodoFileExport", |
|
readme_file: "path/to/Readme.md" # |
|
).export! |
|
|
|
# with readme as just another file |
|
export_2 = ZenodoFileExport.new( |
|
files: ["path/to/alm_report.zip", "path/to/readme.zip"], |
|
export_type: "AlmStatsZenodoFileExport", |
|
readme_file: "path/to/Readme.md" |
|
).export! |
|
|
|
# At this point in time export_2 will have the following settings: |
|
# * IsPreviousVersionOf relation will not be set |
|
# * IsPartOf relation will be export_1's DOI |
|
# * IsNewerVersionOf relation will be set to export_1's DOI |
|
|
|
# export_1 will have the following settings: |
|
# * IsPreviousVersionOf relation will be set to export_2's DOi |
|
# * IsPartOf relation will not be set |
|
# * IsNewerVersionOf relation will not be set |
|
|
|
|
|
export_3 = ZenodoFileExport.new( |
|
files: ["path/to/alm_report.zip"], |
|
export_type: "AlmStatsZenodoFileExport" |
|
).export! |
|
|
|
# At this point in time export_3 will have the following settings: |
|
# * IsPreviousVersionOf relation will not be set |
|
# * IsPartOf relation will be export_1's DOI |
|
# * IsNewerVersionOf relation will be set to export_2's DOI |
|
|
|
# export_2 will have the following settings: |
|
# * IsPreviousVersionOf relation will be set to export_3's DOi |
|
# * IsPartOf relation will be set to export_1's DOI |
|
# * IsNewerVersionOf relation will be set to export_1's DOI |
|
|
|
# export_1 will have the following settings: |
|
# * IsPreviousVersionOf relation will be set to export_2's DOi |
|
# * IsPartOf relation will not be set |
|
# * IsNewerVersionOf relation will not be set |
|
|
|
|
|
# export_2 will have the following settings: |
|
# * IsPartOf relation will be export_1's DOI |
|
# * IsNewerVersionOf relation will be set to export_1's DOI |
|
|