active_fedora-noid 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/README.md +34 -3
- data/lib/active_fedora/noid/config.rb +1 -1
- data/lib/active_fedora/noid/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/config_spec.rb +9 -1
- data/spec/unit/noid_spec.rb +1 -1
- data/spec/unit/service_spec.rb +1 -2
- data/spec/unit/synchronized_minter_spec.rb +1 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ccbc2239b7c60748fb0fde64de2810dae5bc1ec
|
4
|
+
data.tar.gz: c76dd79fe28f8d2304f7d9e2e167b286a3a9a07d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d87e041f9caacf82a0ec9c69bb7860b08925deedbfec266352b64436038c0a11645deca8652ed1b31f1963c6d10f4c449041bcdeb8f8d2b8df2e6467f25d19ed
|
7
|
+
data.tar.gz: 4da0a6a9178291ab0bd1aa947f280bea8841cd578a5b9e990afeb2c3833165bd6150fe4b8d4679f8b3f59993fa11e4215b933d3d94313e0288169fb15829b00b
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[![API Docs](http://img.shields.io/badge/API-docs-blue.svg)](http://rubydoc.info/gems/active_fedora-noid)
|
5
5
|
[![Build Status](https://travis-ci.org/projecthydra-labs/active_fedora-noid.png?branch=master)](https://travis-ci.org/projecthydra-labs/active_fedora-noid)
|
6
6
|
[![Dependency Status](https://gemnasium.com/projecthydra-labs/active_fedora-noid.png)](https://gemnasium.com/projecthydra-labs/active_fedora-noid)
|
7
|
-
[![Coverage Status](https://
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/projecthydra-labs/active_fedora-noid/badge.svg)](https://coveralls.io/r/projecthydra-labs/active_fedora-noid)
|
8
8
|
|
9
9
|
# ActiveFedora::Noid
|
10
10
|
|
@@ -12,6 +12,20 @@ Override your ActiveFedora-based applications with opaque [Noid](https://wiki.uc
|
|
12
12
|
|
13
13
|
**This gem depends only upon ActiveFedora, not on Hydra or HydraHead**
|
14
14
|
|
15
|
+
# Table of Contents
|
16
|
+
|
17
|
+
* [Installation](#installation)
|
18
|
+
* [Usage](#usage)
|
19
|
+
* [Minting and validating identifiers](#minting-and-validating-identifiers)
|
20
|
+
* [ActiveFedora integration](#activefedora-integration)
|
21
|
+
* [Identifier/URI translation](#identifieruri-translation)
|
22
|
+
* [Overriding default behavior](#overriding-default-behavior)
|
23
|
+
* [Minter state (for replayability)](#minter-state-for-replayability)
|
24
|
+
* [Identifier template](#identifier-template)
|
25
|
+
* [Custom minters](#custom-minters)
|
26
|
+
* [Help](#help)
|
27
|
+
* [Acknowledgments](#acknowledgments)
|
28
|
+
|
15
29
|
# Installation
|
16
30
|
|
17
31
|
Add this line to your application's Gemfile:
|
@@ -37,7 +51,7 @@ noid_service = ActiveFedora::Noid::Service.new
|
|
37
51
|
noid = noid_service.mint
|
38
52
|
```
|
39
53
|
|
40
|
-
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
|
54
|
+
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:
|
41
55
|
|
42
56
|
```ruby
|
43
57
|
noid_service.valid? 'xyz123foobar'
|
@@ -69,9 +83,22 @@ class MyObject < ActiveFedora::Base
|
|
69
83
|
end
|
70
84
|
```
|
71
85
|
|
86
|
+
### Identifier/URI translation
|
87
|
+
|
88
|
+
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`:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
ActiveFedora::Base.translate_uri_to_id = ActiveFedora::Noid.config.translate_uri_to_id
|
92
|
+
ActiveFedora::Base.translate_id_to_uri = ActiveFedora::Noid.config.translate_id_to_uri
|
93
|
+
```
|
94
|
+
|
95
|
+
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`).
|
96
|
+
|
72
97
|
## Overriding default behavior
|
73
98
|
|
74
|
-
|
99
|
+
### Minter state (for replayability)
|
100
|
+
|
101
|
+
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`:
|
75
102
|
|
76
103
|
```ruby
|
77
104
|
require 'active_fedora/noid'
|
@@ -81,6 +108,8 @@ ActiveFedora::Noid.configure do |config|
|
|
81
108
|
end
|
82
109
|
```
|
83
110
|
|
111
|
+
### Identifier template
|
112
|
+
|
84
113
|
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`:
|
85
114
|
|
86
115
|
```ruby
|
@@ -93,6 +122,8 @@ end
|
|
93
122
|
|
94
123
|
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).
|
95
124
|
|
125
|
+
### Custom minters
|
126
|
+
|
96
127
|
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:
|
97
128
|
|
98
129
|
```ruby
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/config_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActiveFedora::Noid::Config do
|
4
4
|
it { is_expected.to respond_to(:template) }
|
@@ -23,4 +23,12 @@ describe ActiveFedora::Noid::Config do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
describe '#translate_uri_to_id' do
|
28
|
+
let(:translator) { described_class.new.translate_uri_to_id }
|
29
|
+
let(:uri) { "http://localhost:8983/fedora/rest/test/hh/63/vz/22/hh63vz22q/members" }
|
30
|
+
subject { translator.call(uri) }
|
31
|
+
|
32
|
+
it { is_expected.to eq 'hh63vz22q/members' }
|
33
|
+
end
|
26
34
|
end
|
data/spec/unit/noid_spec.rb
CHANGED
data/spec/unit/service_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_fedora-noid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael J. Giarlo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active-fedora
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.4.
|
128
|
+
rubygems_version: 2.4.8
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Noid identifier services for ActiveFedora-based applications
|
@@ -135,3 +135,4 @@ test_files:
|
|
135
135
|
- spec/unit/noid_spec.rb
|
136
136
|
- spec/unit/service_spec.rb
|
137
137
|
- spec/unit/synchronized_minter_spec.rb
|
138
|
+
has_rdoc:
|