GithubHelp home page GithubHelp logo

samvera-labs / hydra-remote_identifier Goto Github PK

View Code? Open in Web Editor NEW
2.0 38.0 7.0 118 KB

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

License: Other

Ruby 99.91% Shell 0.09%

hydra-remote_identifier's Introduction

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

hydra-remote_identifier's People

Contributors

jeremyf avatar kelynch avatar pfeeley avatar scherztc avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hydra-remote_identifier's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.