Class: ResearchMetadata::Transformer::ResearchOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/research_metadata/transformer/research_output.rb

Overview

Note:

Do not use directly.

Extracts research output metadata from the Pure Research Information System and converts it into the DataCite format. For text-based resources.

Direct Known Subclasses

Thesis

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ ResearchOutput

Returns a new instance of ResearchOutput.

Parameters:

  • config (Hash)

Options Hash (config):

  • :url (String)

    URL of the Pure host

  • :username (String)

    Username of the Pure host account

  • :password (String)

    Password of the Pure host account

  • :api_key (String)

    API key of the Pure host account



17
18
19
20
# File 'lib/research_metadata/transformer/research_output.rb', line 17

def initialize(config)
  @config = config
  @research_output_extractor = Puree::Extractor::ResearchOutput.new config
end

Instance Method Details

#transform(id:, doi:) ⇒ String?

Research output transformation

Parameters:

  • id (String)
  • doi (String)

Returns:

  • (String, nil)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/research_metadata/transformer/research_output.rb', line 27

def transform(id:, doi:)
  begin
    @research_output = @research_output_extractor.find id
    return nil if !@research_output
    person_o = person
    file_o = file
    resource = ::Datacite::Mapping::Resource.new(
        identifier: identifier(doi),
        creators: person_o['creator'],
        titles: titles,
        publication_year: publication_year,
        publisher: publisher,
        subjects: subjects,
        contributors: person_o['contributor'],
        language: language,
        resource_type: resource_type,
        sizes: sizes(file_o),
        formats: formats(file_o),
        rights_list: rights_list(file_o),
        descriptions: description
    )
    resource.write_xml
  rescue => error
    raise error
  end
end