hydra-remote_identifier 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/generators/hydra/remote_identifier/doi_generator.rb +1 -0
- data/lib/hydra/remote_identifier/configuration.rb +6 -3
- data/lib/hydra/remote_identifier/minter.rb +1 -0
- data/lib/hydra/remote_identifier/version.rb +1 -1
- data/lib/hydra/remote_identifier.rb +3 -4
- data/spec/lib/hydra/remote_identifier/minter_spec.rb +1 -1
- data/spec/lib/hydra/remote_identifier/minting_coordinator_spec.rb +2 -2
- data/spec/lib/hydra/remote_identifier_spec.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd5ebaf5e75ba163755a2f32c2c68be67356055c
|
4
|
+
data.tar.gz: 044e7aa00ad6079cb05f47251b48782b29061fe3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3fe0b25361efc0dad12e9cd85587423221412acea745ba7df2145e85ec387108e1518bb929bdc0a05d820fccfe28c77485dc949d58fd89002458d4887531fa6
|
7
|
+
data.tar.gz: ca390ae0f68802254da1839102e468fe69d81ddb21a59a38902ac1c51ffa8a2557d79eae83623d209c67c3fd6ae68a62926651fca457826708cf02fcce97c717
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/hydra-remote_identifier.png)](http://badge.fury.io/rb/hydra-remote_identifier)
|
4
4
|
[![Build Status](https://travis-ci.org/jeremyf/hydra-remote_identifier.png)](https://travis-ci.org/jeremyf/hydra-remote_identifier)
|
5
5
|
|
6
|
-
|
7
6
|
Coordinate the registration and minting of remote identifiers for persisted
|
8
7
|
objects.
|
9
8
|
|
@@ -42,9 +41,10 @@ end
|
|
42
41
|
```
|
43
42
|
|
44
43
|
If you are using Rails, you can run `rails generate hydra:remote_identifier:install` to
|
45
|
-
create a Rails initializer with
|
44
|
+
create a Rails initializer with a configuration stub file. Also available is
|
45
|
+
`rails generate hydra:remote_identifier:doi`.
|
46
46
|
|
47
|
-
In your views allow users to request that a remote identifier be assigned:
|
47
|
+
In your views allow users to request that a remote identifier be created/assigned:
|
48
48
|
|
49
49
|
```ruby
|
50
50
|
<%= form_for book do |f| %>
|
@@ -14,6 +14,7 @@ class Hydra::RemoteIdentifier::DoiGenerator < Rails::Generators::Base
|
|
14
14
|
argument :targets, :type => :array, :default => [], :banner => "class_name class_name"
|
15
15
|
|
16
16
|
def insert_doi
|
17
|
+
|
17
18
|
inject_into_file(
|
18
19
|
"config/initializers/hydra-remote_identifier_config.rb",
|
19
20
|
after: /Hydra::RemoteIdentifier.*/
|
@@ -17,7 +17,7 @@ module Hydra::RemoteIdentifier
|
|
17
17
|
attr_reader :remote_services
|
18
18
|
|
19
19
|
def find_remote_service(service_name)
|
20
|
-
remote_services.fetch(service_name)
|
20
|
+
remote_services.fetch(service_name.to_sym)
|
21
21
|
end
|
22
22
|
|
23
23
|
# @param service_name [#to_s]
|
@@ -25,14 +25,17 @@ module Hydra::RemoteIdentifier
|
|
25
25
|
#
|
26
26
|
# @yieldparam [Registration]
|
27
27
|
def remote_service(service_name, *args)
|
28
|
-
remote_service =
|
29
|
-
remote_services[service_name] = remote_service
|
28
|
+
remote_service = find_or_store_remote_service(service_name, *args)
|
30
29
|
registration = registration_builder.new(remote_service)
|
31
30
|
yield(registration)
|
32
31
|
remote_service
|
33
32
|
end
|
34
33
|
|
35
34
|
private
|
35
|
+
def find_or_store_remote_service(service_name, *args)
|
36
|
+
remote_services[service_name.to_sym] ||= remote_service_class_lookup(service_name).new(*args)
|
37
|
+
remote_services.fetch(service_name.to_sym)
|
38
|
+
end
|
36
39
|
|
37
40
|
def remote_service_class_lookup(string)
|
38
41
|
remote_service_class_name = string.to_s.gsub(/(?:^|_)([a-z])/) { $1.upcase }
|
@@ -108,12 +108,11 @@ module Hydra::RemoteIdentifier
|
|
108
108
|
# @param target [#registered_remote_identifier_minters]
|
109
109
|
def mint(remote_service_name, target)
|
110
110
|
return false unless target.respond_to?(:registered_remote_identifier_minters)
|
111
|
-
|
112
|
-
# @TODO - there is a better way to do this but this is "complete/correct"
|
113
111
|
remote_service = configuration.find_remote_service(remote_service_name)
|
114
|
-
target.registered_remote_identifier_minters.
|
115
|
-
|
112
|
+
coordinator = target.registered_remote_identifier_minters.detect do |c|
|
113
|
+
c.remote_service.name == remote_service.name
|
116
114
|
end
|
115
|
+
coordinator.call(target) if coordinator
|
117
116
|
end
|
118
117
|
|
119
118
|
end
|
@@ -17,7 +17,7 @@ module Hydra::RemoteIdentifier
|
|
17
17
|
it "extracts the target's payload to send to the remote service then updates the target's identifier" do
|
18
18
|
service.should_receive(:call).with(payload).and_return(identifier)
|
19
19
|
target.should_receive(:set_identifier).with(identifier)
|
20
|
-
subject.call
|
20
|
+
expect(subject.call).to eq(identifier)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -9,8 +9,8 @@ module Hydra::RemoteIdentifier
|
|
9
9
|
subject { MintingCoordinator.new(remote_service, mapper_builder, &map) }
|
10
10
|
it 'forward delegates call to the minter' do
|
11
11
|
minter = double
|
12
|
-
minter.should_receive(:call).with(remote_service, :wrapped_target)
|
13
|
-
subject.call(target, minter)
|
12
|
+
minter.should_receive(:call).with(remote_service, :wrapped_target).and_return(:response)
|
13
|
+
expect(subject.call(target, minter)).to eq(:response)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -93,6 +93,10 @@ module Hydra::RemoteIdentifier
|
|
93
93
|
}.to change(target, :set_identifier).from(nil).to(expected_doi)
|
94
94
|
end
|
95
95
|
|
96
|
+
it 'returns the newly minted identifier', VCR::SpecSupport(record: :new_episodes, cassette_name: 'doi-integration') do
|
97
|
+
expect(Hydra::RemoteIdentifier.mint(:doi, target)).to eq(expected_doi)
|
98
|
+
end
|
99
|
+
|
96
100
|
it 'returns false if the target is not configured for identifiers' do
|
97
101
|
expect(Hydra::RemoteIdentifier.mint(:doi, double)).to eq(false)
|
98
102
|
end
|