hydra-remote_identifier 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f98bb8113e7148bed0364b4a49a438d70a21ed83
4
- data.tar.gz: ae8a740d87e58916eb53df0a5bf3897ade3dd7bc
3
+ metadata.gz: 9bfdfcaee94b94b71118befacfc086df017d23cf
4
+ data.tar.gz: 3e99f645cbd73f4217d5bd9ae50a4ef60a9ff254
5
5
  SHA512:
6
- metadata.gz: 8c2e8a60049fddab49d180ee6e9f142553f0b113b0669dae6acc9e84ba0e6ae8f9c8427d8840cab30bf08496efe77cb4de0bf169a0b240151c30e5372530e4c7
7
- data.tar.gz: 1a354e9bd6b9d793b621c607bf9f0d2eb1c045a94f3cd534f1bd369beb4c19d69a0093047ea279bec8a61afce4c7351280cfbb6502ab4e32d6d81a0b2fb55ffb
6
+ metadata.gz: 236c6a8e16274abb3cd508b717a38f46b998ccc7c7c4d712f1d89ff846373ae82b8809f53b6628a0880f9bb0e77a48c34b75ececb9edaafb24b38c08defb6932
7
+ data.tar.gz: 529388f0a159d7eb9c6f3fee8ff9ded2468f7318ac858cddea6a2fdbc0aac0f6ee71af76647befd5f58a0861529dece024f8bd5e689ebb2bb7c7681247f037c3
data/README.md CHANGED
@@ -36,3 +36,22 @@ Configure your remote identifiers with credentials and what have you:
36
36
  end
37
37
  end
38
38
  end
39
+
40
+ In your views allow users to request that a remote identifier be assigned:
41
+
42
+ <%= form_for book do |f| %>
43
+ <% Hydra::RemoteIdentifier.with_registered_remote_service(:doi, f.object) do |remote_service| %>
44
+ <%= f.input remote_service.accessor_name %>
45
+ <% end %>
46
+ <% end %>
47
+
48
+ Where you enqueue an asynchronous worker iterate over the requested identifiers:
49
+
50
+ Hydra::RemoteIdentifier.applicable_remote_service_names_for(book) do |remote_service|
51
+ MintRemoteIdentifierWorker.enqueue(book.to_param, remote_service.name)
52
+ end
53
+
54
+ Where your asynchronouse worker does its work request the minting:
55
+
56
+ # Instantiate target from input
57
+ Hydra::RemoteIdentifier.mint(remote_service_name, target)
@@ -31,10 +31,16 @@ module Hydra::RemoteIdentifier
31
31
  yield(configuration)
32
32
  end
33
33
 
34
+ # Yields the specified RemoteService if it _could_ be requested for the
35
+ # Target.
36
+ #
34
37
  # @example
35
- # Hydra::RemoteIdentifier.with_registered_remote_service(:doi, book) do |remote_service|
36
- # Hydra::RemoteIdentifier.mint(:doi, book)
37
- # end
38
+ # <% Hydra::RemoteIdentifier.with_registered_remote_service(:doi, book) do |remote_service| %>
39
+ # <%= f.input remote_service.accessor_name %>
40
+ # <% end %>
41
+ #
42
+ # @param remote_service_name [#to_s]
43
+ # @param target [#registered_remote_identifier_minters] (see Hydra::RemoteIdentifier.configure)
38
44
  def with_registered_remote_service(remote_service_name, target)
39
45
  # @TODO - the registered remote identifier is more than a bit off;
40
46
  # but it continues to work
@@ -45,11 +51,21 @@ module Hydra::RemoteIdentifier
45
51
  }
46
52
  end
47
53
 
54
+
55
+ # Yields each RemoteService#name that _is_ requested for the Target.
56
+ #
57
+ # @example
58
+ # Hydra::RemoteIdentifier.requested_remote_identifiers_for(book) do |remote_service_name|
59
+ # Hydra::RemoteIdentifier.mint(remote_service_name, book)
60
+ # end
61
+ #
62
+ # @param target [#registered_remote_identifier_minters] (see Hydra::RemoteIdentifier.configure)
63
+ # @yield_param remote_service_name [#to_s]
48
64
  def requested_remote_identifiers_for(target)
49
65
  target.registered_remote_identifier_minters.each do |coordinator|
50
66
  remote_service = coordinator.remote_service
51
67
  if target.public_send(remote_service.accessor_name).to_i != 0
52
- yield(remote_service.name)
68
+ yield(remote_service)
53
69
  end
54
70
  end
55
71
  end
@@ -58,12 +74,11 @@ module Hydra::RemoteIdentifier
58
74
  # the target. You must first configure the RemoteService and target's class
59
75
  # to define the attribute map. See Hydra::RemoteIdentifier.configure
60
76
  #
61
- #
62
77
  # @example
63
78
  # Hydra::RemoteIdentifier.mint(:doi, book)
64
79
  #
65
80
  # @param remote_service_name [#to_s]
66
- # @param target [#registered_remote_identifier_minters]
81
+ # @param target [#registered_remote_identifier_minters] (see Hydra::RemoteIdentifier.configure)
67
82
  def mint(remote_service_name, target)
68
83
  # @TODO - there is a better way to do this but this is "complete/correct"
69
84
  remote_service = configuration.find_remote_service(remote_service_name)
@@ -12,6 +12,10 @@ module Hydra::RemoteIdentifier
12
12
  self.class.to_s.demodulize.underscore.to_sym
13
13
  end
14
14
 
15
+ def to_s
16
+ name.to_s
17
+ end
18
+
15
19
  def accessor_name
16
20
  "mint_#{name}".to_sym
17
21
  end
@@ -1,5 +1,5 @@
1
1
  module Hydra
2
2
  module RemoteIdentifier
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
@@ -9,6 +9,7 @@ module Hydra::RemoteIdentifier
9
9
 
10
10
  its(:name) { should eq :remote_service }
11
11
  its(:accessor_name) { should eq :mint_remote_service }
12
+ its(:to_s) { should eq 'remote_service' }
12
13
 
13
14
  context '#call' do
14
15
  it { expect { subject.call(payload) }.to raise_error NotImplementedError }
@@ -77,7 +77,7 @@ module Hydra::RemoteIdentifier
77
77
  target.mint_doi = '1'
78
78
  expect { |block|
79
79
  Hydra::RemoteIdentifier.requested_remote_identifiers_for(target, &block)
80
- }.to yield_with_args(:doi)
80
+ }.to yield_with_args(instance_of(RemoteServices::Doi))
81
81
  end
82
82
 
83
83
  it 'should not yield when the remote identifier was not requested' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-remote_identifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen