Metadata extraction from the Pure Research Information System and transformation of the metadata into an announcement.

extraction, metadata, research, transformations
gem install research_metadata_announcement -v 0.5.2



Metadata extraction from the Pure Research Information System and transformation of the metadata into an announcement.


Gem Version Build Status Code Climate


Add this line to your application's Gemfile:

gem 'research_metadata_announcement'

And then execute:

$ bundle

Or install it yourself as:

$ gem install research_metadata_announcement



Create a hash for passing to a transformer.

# Pure host with authentication.
config = {
  url:      ENV['PURE_URL'],
  username: ENV['PURE_USERNAME'],
  password: ENV['PURE_PASSWORD'],
# Pure host without authentication.
config = {
  url: ENV['PURE_URL']


Create a metadata transformer for a Pure dataset.

transformer = config

Give it a Pure identifier and get an announcement.

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'

Optionally, use the :composition keyword argument to pass in an array of components (duplicates are ignored). The order of the components determines the order of the metadata in the announcement.

Possible components:

:new, :title, :keywords, :hashtags, :uri

Ideally, an announcement will be obtained using all the requested components, with the following exceptions:

  • If the composition includes :keywords or :hashtags and the resource does not have any descriptors, the metadata is simply omitted.

  • If the composition includes :uri, the resource must have a URI for an announcement to be returned.

  • If, after :title truncation/removal, the length still exceeds the optional :max_length keyword argument, an announcement will not be returned.

If the composition includes :new, a phrase based upon the resource type is generated e.g. New dataset. However, this gem does not determine whether the resource is deemed to be new.

Each example uses a different resource for illustrative purposes.

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
#=> "New publication. Can poly-parameter linear-free energy relationships (pp-LFERs) improve modelling bioaccumulation in fish? #partitioncoefficients #pplfer."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', max_length: 140
#=> "New publication. The Parting of Burroughs and... #americancounterculture #arthurrimbaud."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:new, :title, :hashtags] # resource has no descriptors
#=> "New publication. Deductive and inductive data collection for agent-based modelling."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:new, :title, :keywords, :uri]
#=> "New publication. Torsion pairs in a triangulated category generated by a spherical object. Auslander–Reiten theory, Calabi–Yau triangulated category."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:new, :title, :uri]
#=> "New dataset. Operating Nanobeams in a Quantum Fluid."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:uri, :title]
#=> " Herpes simplex virus 1 (HSV-1) evolution."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:keywords, :uri]
#=> "smart cities, sustainability."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:hashtags, :uri]
#=> "#treatedhypertension #microvascularbloodflow."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:uri, :keywords]
#=> " metagenomics, deep sequencing."

transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', composition: [:uri, :hashtags], max_descriptors: 4
#=> " #influenza #nasopharynx #virology #virus."