No release in over 3 years
Low commit activity in last 3 years
Handles the registration and minting of remote identifiers (i.e. DOI, ARK, ORCID)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
~> 2.14

Runtime

< 5.0, >= 3.2.13
~> 1.6.7
 Project Readme

Hydra::RemoteIdentifier

Gem Version Build Status

Coordinate the registration and minting of remote identifiers for persisted objects.

Installation

Add this line to your application's Gemfile:

gem 'hydra-remote_identifier'

And then execute:

$ bundle

Or install it yourself as:

$ gem install hydra-remote_identifier

Usage

Configure your remote identifiers with credentials and what have you:

doi_credentials = Psych.load('/path/to/doi_credentials.yml')
Hydra::RemoteIdentifier.configure do |config|
  config.remote_service(:doi, doi_credentials) do |doi|
    doi.register(Book, Page) do |map|
      map.target :url
      map.creator {|obj| obj.person_name }
      map.title :title
      map.publisher :publisher
      map.publicationyear :publicationyear
      map.set_identifier(:set_identifier=)
    end
  end
end

If you are using Rails, you can run rails generate hydra:remote_identifier:install to create a Rails initializer with a configuration stub file. Also available is rails generate hydra:remote_identifier:doi.

In your views allow users to request that a remote identifier be created/assigned:

<%= form_for book do |f| %>
  <% Hydra::RemoteIdentifier.registered?(:doi, f.object) do |remote_service| %>
    <%= f.input remote_service.accessor_name %>
  <% end %>
<% end %>

Where you enqueue an asynchronous worker iterate over the requested identifiers:

Hydra::RemoteIdentifier.applicable_remote_service_names_for(book) do |remote_service|
  MintRemoteIdentifierWorker.enqueue(book.to_param, remote_service.name)
end

Where your asynchronous worker does its work request the minting:

# Instantiate target from input
Hydra::RemoteIdentifier.mint(remote_service_name, target)

In your show views you can provide a link to the remote identifier via Hydra::RemoteIdentifier.remote_uri_for:

<%= link_to(object.doi, Hydra::RemoteIdentifier.remote_uri_for(:doi, object.doi)) %>

Extending Hydra::RemoteIdentifier with alternate remote identifiers

If you are interested in creating a new Hydra::RemoteIdentifier::RemoteService, this can be done by creating a class in the Hydra::RemoteIdentifier::RemoteServices namespace. See below:

module Hydra::RemoteIdentifier::RemoteServices
  class MyRemoteService < Hydra::RemoteIdentifier::RemoteService
    # your code here
  end
end

Then configure your RemoteService for your persisted targets. See below:

Hydra::RemoteIdentifier.configure do |config|
  config.remote_service(:my_remote_service, credentials) do |mine|
    mine.register(Book, Page) do |map|
      # map fields of Book, Page to the required payload for MyRemoteService
    end
  end
end