Class: ROF::Translators::OsfToRof
- Inherits:
-
ROF::Translator
- Object
- ROF::Translator
- ROF::Translators::OsfToRof
- Defined in:
- lib/rof/translators/osf_to_rof.rb
Overview
Class for managing OSF Archive data transformations It is called after the get-from-osf task, and before the work-xlat task
Class Method Summary collapse
-
.call(project, config, previously_archived_pid_finder = default_previously_archived_pid_finder) ⇒ Object
Convert Osf Archive tar.gz to ROF.
- .default_previously_archived_pid_finder ⇒ #call
Instance Method Summary collapse
- #archive_type ⇒ Object private
- #call ⇒ Object
-
#initialize(project, config, previously_archived_pid_finder = self.class.default_previously_archived_pid_finder) ⇒ OsfToRof
constructor
A new instance of OsfToRof.
- #osf_project_identifier ⇒ Object private
-
#source_slug ⇒ Object
private
This is a bit of a misnomer; As used it represents the path to the project or registration that we have ingested (e.g. osf.io/:source_slug).
Constructor Details
#initialize(project, config, previously_archived_pid_finder = self.class.default_previously_archived_pid_finder) ⇒ OsfToRof
Returns a new instance of OsfToRof.
25 26 27 28 29 30 |
# File 'lib/rof/translators/osf_to_rof.rb', line 25 def initialize(project, config, previously_archived_pid_finder = self.class.default_previously_archived_pid_finder) @config = config @project = project @previously_archived_pid_finder = previously_archived_pid_finder @osf_map = ROF::OsfToNDMap end |
Class Method Details
.call(project, config, previously_archived_pid_finder = default_previously_archived_pid_finder) ⇒ Object
Convert Osf Archive tar.gz to ROF
21 22 23 |
# File 'lib/rof/translators/osf_to_rof.rb', line 21 def self.call(project, config, previously_archived_pid_finder = default_previously_archived_pid_finder) new(project, config, previously_archived_pid_finder).call end |
.default_previously_archived_pid_finder ⇒ #call
Set this to be something more meaningful than an empty lambda
16 17 18 |
# File 'lib/rof/translators/osf_to_rof.rb', line 16 def self.default_previously_archived_pid_finder ->(archive_type, osf_project_identifier) {} end |
Instance Method Details
#archive_type ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 |
# File 'lib/rof/translators/osf_to_rof.rb', line 42 def archive_type project.fetch('package_type') end |
#call ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/rof/translators/osf_to_rof.rb', line 32 def call rof_array = [] return {} if project.nil? @ttl_data = ttl_from_targz(source_slug + '.ttl') rof_array[0] = build_archive_record rof_array end |
#osf_project_identifier ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 |
# File 'lib/rof/translators/osf_to_rof.rb', line 60 def osf_project_identifier return source_slug if project['package_type'] == 'OSF Project' osf_url_from_filename(ttl_data[0][@osf_map['registeredFrom']][0]['@id']) end |
#source_slug ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This is a bit of a misnomer; As used it represents the path to the project or registration that we have ingested (e.g. osf.io/:source_slug)
It was previously named :project_identifier in this class, but that gets conflated with the underlying object’s osf_project_identifier (e.g. what OSF Project was this archive originally based on)
54 55 56 |
# File 'lib/rof/translators/osf_to_rof.rb', line 54 def source_slug project.fetch('project_identifier') end |