README.md in active_fedora-noid-0.2.0 vs README.md in active_fedora-noid-0.3.0
- old
+ new
@@ -2,18 +2,32 @@
[![Apache 2.0 License](http://img.shields.io/badge/APACHE2-license-blue.svg)](./LICENSE)
[![Contribution Guidelines](http://img.shields.io/badge/CONTRIBUTING-Guidelines-blue.svg)](./CONTRIBUTING.md)
[![API Docs](http://img.shields.io/badge/API-docs-blue.svg)](http://rubydoc.info/gems/active_fedora-noid)
[![Build Status](https://travis-ci.org/projecthydra-labs/active_fedora-noid.png?branch=master)](https://travis-ci.org/projecthydra-labs/active_fedora-noid)
[![Dependency Status](https://gemnasium.com/projecthydra-labs/active_fedora-noid.png)](https://gemnasium.com/projecthydra-labs/active_fedora-noid)
-[![Coverage Status](https://img.shields.io/coveralls/projecthydra-labs/active_fedora-noid.svg)](https://coveralls.io/r/projecthydra-labs/active_fedora-noid?branch=master)
+[![Coverage Status](https://coveralls.io/repos/projecthydra-labs/active_fedora-noid/badge.svg)](https://coveralls.io/r/projecthydra-labs/active_fedora-noid)
# ActiveFedora::Noid
Override your ActiveFedora-based applications with opaque [Noid](https://wiki.ucop.edu/display/Curation/NOID)-based identifiers.
**This gem depends only upon ActiveFedora, not on Hydra or HydraHead**
+# Table of Contents
+
+ * [Installation](#installation)
+ * [Usage](#usage)
+ * [Minting and validating identifiers](#minting-and-validating-identifiers)
+ * [ActiveFedora integration](#activefedora-integration)
+ * [Identifier/URI translation](#identifieruri-translation)
+ * [Overriding default behavior](#overriding-default-behavior)
+ * [Minter state (for replayability)](#minter-state-for-replayability)
+ * [Identifier template](#identifier-template)
+ * [Custom minters](#custom-minters)
+ * [Help](#help)
+ * [Acknowledgments](#acknowledgments)
+
# Installation
Add this line to your application's Gemfile:
gem 'active_fedora-noid'
@@ -35,11 +49,11 @@
```ruby
noid_service = ActiveFedora::Noid::Service.new
noid = noid_service.mint
```
-This creates a Noid with the default identifier template, which you can override (see below). Now that you have a service object with a template, you can also use it to validate identifier to see if they conform to the template:
+This creates a Noid with the default identifier template, which you can override (see below). Now that you have a service object with a template, you can also use it to validate identifiers to see if they conform to the template:
```ruby
noid_service.valid? 'xyz123foobar'
> false
```
@@ -67,22 +81,37 @@
@noid_service ||= ActiveFedora::Noid::Service.new
end
end
```
+### Identifier/URI translation
+
+As ActiveFedora::Noid overrides the default identifier minting strategy in ActiveFedora, you will need to let ActiveFedora know how to translate identifiers into URIs and vice versa so that identifiers are laid out in a sustainable way in Fedora. Add the following to e.g. `config/initializers/active_fedora.rb`:
+
+```ruby
+ActiveFedora::Base.translate_uri_to_id = ActiveFedora::Noid.config.translate_uri_to_id
+ActiveFedora::Base.translate_id_to_uri = ActiveFedora::Noid.config.translate_id_to_uri
+```
+
+This will make sure your objects have Noid-like identifiers (e.g. `bb22bb22b`) that map to URIs in Fedora (e.g. `bb/22/bb/22/bb22bb22b`).
+
## Overriding default behavior
-The default minter creates a Noid and dumps it to a statefile in the /tmp directory. You can override the location or name of this statefile as follows:
+### Minter state (for replayability)
+The default minter creates a Noid and dumps it to a statefile in the /tmp directory. You can override the location or name of this statefile as follows in e.g. `config/initializers/active_fedora-noid.rb`:
+
```ruby
require 'active_fedora/noid'
ActiveFedora::Noid.configure do |config|
config.statefile = '/var/foo/bar'
end
```
+### Identifier template
+
To override the default identifier pattern -- a nine-character string consisting of two alphanumeric digits, two numeric digits, two alphanumeric digits, two numeric digits, and a check digit -- put the following code in e.g. `config/initializers/active_fedora-noid.rb`:
```ruby
require 'active_fedora/noid'
@@ -90,9 +119,11 @@
config.template = '.ddddd'
end
```
For more information about the format of Noid patterns, see pages 8-10 of the [Noid documentation](https://wiki.ucop.edu/download/attachments/16744482/noid.pdf).
+
+### Custom minters
If you don't want your minter's state to be persisted, you may also pass in your own minter. First write up a minter class that looks like the following:
```ruby
class MyMinter