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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83ec9c5f0edbe298c0b6fa8371eef1ec7af1651a
4
- data.tar.gz: ef4f8031eaf4e0bab414882c4e46e49e67dd7841
3
+ metadata.gz: 8ccbc2239b7c60748fb0fde64de2810dae5bc1ec
4
+ data.tar.gz: c76dd79fe28f8d2304f7d9e2e167b286a3a9a07d
5
5
  SHA512:
6
- metadata.gz: 38f935884a4bb63bc70d10d54fc5ff56c7fde95740954c69af86d717887439427565243518ce2918b65999315ddd0d873ff0db0f325a593398fa79f04d6c4e39
7
- data.tar.gz: 03fc4dcfc8c764a650e1f5d03e4769fa88e4fd2ffaa177d3f781bd9d89ab10d3b9fe0e5668a8db2a5ed6bd8b43690494f7d9e689b3ebcbde4e1cb158f8ef625e
6
+ metadata.gz: d87e041f9caacf82a0ec9c69bb7860b08925deedbfec266352b64436038c0a11645deca8652ed1b31f1963c6d10f4c449041bcdeb8f8d2b8df2e6467f25d19ed
7
+ data.tar.gz: 4da0a6a9178291ab0bd1aa947f280bea8841cd578a5b9e990afeb2c3833165bd6150fe4b8d4679f8b3f59993fa11e4215b933d3d94313e0288169fb15829b00b
data/.travis.yml CHANGED
@@ -15,7 +15,6 @@ notifications:
15
15
  on_failure: "always"
16
16
  irc:
17
17
  channels:
18
- - "irc.freenode.org#scholarsphere"
19
18
  - "irc.freenode.org#projecthydra"
20
19
  template:
21
20
  - "%{repository}//%{branch}@%{commit} by %{author}: %{message} - %{build_url}"
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://img.shields.io/coveralls/projecthydra-labs/active_fedora-noid.svg)](https://coveralls.io/r/projecthydra-labs/active_fedora-noid?branch=master)
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 identifier to see if they conform to the template:
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
- 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:
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
@@ -12,7 +12,7 @@ module ActiveFedora
12
12
  end
13
13
 
14
14
  def translate_uri_to_id
15
- lambda { |uri| uri.to_s.split('/')[-1] }
15
+ lambda { |uri| URI(uri).path.split('/', 9).last }
16
16
  end
17
17
 
18
18
  def translate_id_to_uri
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora
2
2
  module Noid
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'coveralls'
2
2
  Coveralls.wear!
3
3
 
4
+ require 'active_fedora/noid'
5
+
4
6
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
5
7
  RSpec.configure do |config|
6
8
  # rspec-expectations config goes here. You can use an alternate
@@ -1,4 +1,4 @@
1
- require 'active_fedora/noid/config'
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
@@ -1,4 +1,4 @@
1
- require 'active_fedora/noid'
1
+ require 'spec_helper'
2
2
 
3
3
  describe ActiveFedora::Noid do
4
4
  describe '#configure' do
@@ -1,5 +1,4 @@
1
- require 'active_fedora/noid/service'
2
- require 'active_fedora/noid/synchronized_minter'
1
+ require 'spec_helper'
3
2
 
4
3
  describe ActiveFedora::Noid::Service do
5
4
  describe 'public API' do
@@ -1,6 +1,5 @@
1
+ require 'spec_helper'
1
2
  require 'active_fedora'
2
- require 'active_fedora/noid'
3
- require 'active_fedora/noid/synchronized_minter'
4
3
 
5
4
  describe ActiveFedora::Noid::SynchronizedMinter do
6
5
  it { is_expected.to respond_to(:mint) }
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.2.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-03-31 00:00:00.000000000 Z
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.3
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: