hydra-remote_identifier 0.5.0 → 0.5.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68f852f82865fce51183e6cf178e7ec15cf7cae4
|
4
|
+
data.tar.gz: 5d453454a68027663297d5ee16548590630c1eeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dda3e9b63f470fae42a7c37fc791045c59f0fe8a36cf8142d3e59a38289d6ee48277888f5c21d308bcfdd89103a34baf3c2e02d33f4cf421917e39c3a354ea7
|
7
|
+
data.tar.gz: c3508551c81a135bb5d33b48b3c378df5e92db3312404753c1f4694f63a553adda1557a5495ffded296d877ec3375676dc977a2a76c3f215295bdc0b34907fce
|
data/README.md
CHANGED
@@ -25,46 +25,56 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
Configure your remote identifiers with credentials and what have you:
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
28
|
+
```ruby
|
29
|
+
doi_credentials = Psych.load('/path/to/doi_credentials.yml')
|
30
|
+
Hydra::RemoteIdentifier.configure do |config|
|
31
|
+
config.remote_service(:doi, doi_credentials) do |doi|
|
32
|
+
doi.register(Book, Page) do |map|
|
33
|
+
map.target :url
|
34
|
+
map.creator {|obj| obj.person_name }
|
35
|
+
map.title :title
|
36
|
+
map.publisher :publisher
|
37
|
+
map.publicationyear :publicationyear
|
38
|
+
map.set_identifier(:set_identifier=)
|
40
39
|
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
41
43
|
|
42
44
|
If you are using Rails, you can run `rails generate hydra:remote_identifier:install` to
|
43
45
|
create a Rails initializer with the above stub file.
|
44
46
|
|
45
47
|
In your views allow users to request that a remote identifier be assigned:
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
```ruby
|
50
|
+
<%= form_for book do |f| %>
|
51
|
+
<% Hydra::RemoteIdentifier.with_registered_remote_service(:doi, f.object) do |remote_service| %>
|
52
|
+
<%= f.input remote_service.accessor_name %>
|
53
|
+
<% end %>
|
54
|
+
<% end %>
|
55
|
+
```
|
52
56
|
|
53
57
|
Where you enqueue an asynchronous worker iterate over the requested identifiers:
|
54
58
|
|
55
|
-
|
56
|
-
|
57
|
-
|
59
|
+
```ruby
|
60
|
+
Hydra::RemoteIdentifier.applicable_remote_service_names_for(book) do |remote_service|
|
61
|
+
MintRemoteIdentifierWorker.enqueue(book.to_param, remote_service.name)
|
62
|
+
end
|
63
|
+
```
|
58
64
|
|
59
65
|
Where your asynchronous worker does its work request the minting:
|
60
66
|
|
61
|
-
|
62
|
-
|
67
|
+
```ruby
|
68
|
+
# Instantiate target from input
|
69
|
+
Hydra::RemoteIdentifier.mint(remote_service_name, target)
|
70
|
+
```
|
63
71
|
|
64
72
|
In your show views you can provide a link to the remote identifier via
|
65
73
|
Hydra::RemoteIdentifier.remote_uri_for:
|
66
74
|
|
67
|
-
|
75
|
+
```ruby
|
76
|
+
<%= link_to(object.doi, Hydra::RemoteIdentifier.remote_uri_for(:doi, object.doi)) %>
|
77
|
+
```
|
68
78
|
|
69
79
|
## Extending Hydra::RemoteIdentifier with alternate remote identifiers
|
70
80
|
|
@@ -72,18 +82,22 @@ If you are interested in creating a new Hydra::RemoteIdentifier::RemoteService,
|
|
72
82
|
this can be done by creating a class in the Hydra::RemoteIdentifier::RemoteServices
|
73
83
|
namespace. See below:
|
74
84
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
85
|
+
```ruby
|
86
|
+
module Hydra::RemoteIdentifier::RemoteServices
|
87
|
+
class MyRemoteService < Hydra::RemoteIdentifier::RemoteService
|
88
|
+
# your code here
|
89
|
+
end
|
90
|
+
end
|
91
|
+
```
|
80
92
|
|
81
93
|
Then configure your RemoteService for your persisted targets. See below:
|
82
94
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
95
|
+
```ruby
|
96
|
+
Hydra::RemoteIdentifier.configure do |config|
|
97
|
+
config.remote_service(:my_remote_service, credentials) do |mine|
|
98
|
+
mine.register(Book, Page) do |map|
|
99
|
+
# map fields of Book, Page to the required payload for MyRemoteService
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
```
|
@@ -31,6 +31,9 @@ module Hydra::RemoteIdentifier
|
|
31
31
|
class_attribute :registered_remote_identifier_minters
|
32
32
|
end
|
33
33
|
attr_accessor service.accessor_name
|
34
|
+
define_method("#{service.accessor_name}?") do
|
35
|
+
instance_variable_get("@#{service.accessor_name}").to_i != 0
|
36
|
+
end
|
34
37
|
end
|
35
38
|
target_class.registered_remote_identifier_minters ||= []
|
36
39
|
target_class.registered_remote_identifier_minters += [minting_coordinator.new(remote_service, &map)]
|
@@ -18,11 +18,15 @@ module Hydra::RemoteIdentifier
|
|
18
18
|
}.to change{ target_class.respond_to?(:registered_remote_identifier_minters) }.from(false).to(true)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
context 'adds a #mint_remote_service attribute' do
|
22
|
+
before(:each) do
|
23
|
+
subject.register(target_class, &map)
|
24
|
+
end
|
25
|
+
let(:target) { target_class.new }
|
26
|
+
|
27
|
+
it { expect(target).to respond_to(:mint_my_remote_service) }
|
28
|
+
it { expect(target).to respond_to(:mint_my_remote_service=) }
|
29
|
+
it { expect(target.mint_my_remote_service?).to eq(false) }
|
26
30
|
end
|
27
31
|
|
28
32
|
it 'registers the minting coordinator on the target class' do
|