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: 87813006e82d12d459d9ac9f003a9872092492cf
4
- data.tar.gz: 16fe3b7b203515ef37e87fa1a11a21d6610600ab
3
+ metadata.gz: 68f852f82865fce51183e6cf178e7ec15cf7cae4
4
+ data.tar.gz: 5d453454a68027663297d5ee16548590630c1eeb
5
5
  SHA512:
6
- metadata.gz: 6edb49259d5997f2e0b16939fb8c1424a544c1ed80e5b521681163a30a3295c442b9d00b12cfd20ecd52fd499dde059c6ec14dc18382300ff9051853e3aaaa95
7
- data.tar.gz: 36a347aae24e33b6c93e9fb0355624e580cffe81dc8f16f6850746f64eee253055548016da9f067ccf215a4ea3cbeaea0fb530ccf7230c85116f15625ea330a2
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
- doi_credentials = Psych.load('/path/to/doi_credentials.yml')
29
- Hydra::RemoteIdentifier.configure do |config|
30
- config.remote_service(:doi, doi_credentials) do |doi|
31
- doi.register(Book, Page) do |map|
32
- map.target :url
33
- map.creator {|obj| obj.person_name }
34
- map.title :title
35
- map.publisher :publisher
36
- map.publicationyear :publicationyear
37
- map.set_identifier(:set_identifier=)
38
- end
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
- <%= form_for book do |f| %>
48
- <% Hydra::RemoteIdentifier.with_registered_remote_service(:doi, f.object) do |remote_service| %>
49
- <%= f.input remote_service.accessor_name %>
50
- <% end %>
51
- <% end %>
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
- Hydra::RemoteIdentifier.applicable_remote_service_names_for(book) do |remote_service|
56
- MintRemoteIdentifierWorker.enqueue(book.to_param, remote_service.name)
57
- end
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
- # Instantiate target from input
62
- Hydra::RemoteIdentifier.mint(remote_service_name, target)
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
- <%= link_to(object.doi, Hydra::RemoteIdentifier.remote_uri_for(:doi, object.doi)) %>
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
- module Hydra::RemoteIdentifier::RemoteServices
76
- class MyRemoteService < Hydra::RemoteIdentifier::RemoteService
77
- # your code here
78
- end
79
- end
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
- Hydra::RemoteIdentifier.configure do |config|
84
- config.remote_service(:my_remote_service, credentials) do |mine|
85
- mine.register(Book, Page) do |map|
86
- # map fields of Book, Page to the required payload for MyRemoteService
87
- end
88
- end
89
- end
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)]
@@ -1,5 +1,5 @@
1
1
  module Hydra
2
2
  module RemoteIdentifier
3
- VERSION = "0.5.0"
3
+ VERSION = "0.5.1"
4
4
  end
5
5
  end
@@ -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
- it 'adds a #mint_remote_service attribute' do
22
- subject.register(target_class, &map)
23
- target = target_class.new
24
- expect(target).to respond_to(:mint_my_remote_service)
25
- expect(target).to respond_to(:mint_my_remote_service=)
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
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.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen