ezid-client 1.6.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +35 -0
- data/README.md +59 -13
- data/Rakefile +6 -6
- data/VERSION +1 -1
- data/ezid-client.gemspec +5 -3
- data/lib/ezid/{batch_enumerator.rb → batch.rb} +2 -2
- data/lib/ezid/batch_download.rb +4 -0
- data/lib/ezid/client.rb +11 -10
- data/lib/ezid/configuration.rb +11 -4
- data/lib/ezid/error.rb +2 -0
- data/lib/ezid/identifier.rb +57 -20
- data/lib/ezid/metadata.rb +11 -1
- data/lib/ezid/metadata_transforms/datacite.rb +72 -0
- data/lib/ezid/requests/request.rb +22 -9
- data/lib/ezid/responses/response.rb +13 -0
- data/spec/fixtures/datacite_xml/empty.xml +1 -0
- data/spec/fixtures/datacite_xml/populated.xml +1 -0
- data/spec/integration/batch_download_spec.rb +4 -4
- data/spec/integration/client_spec.rb +1 -1
- data/spec/integration/identifier_spec.rb +3 -2
- data/spec/spec_helper.rb +4 -2
- data/spec/unit/{batch_enumerator_spec.rb → batch_spec.rb} +2 -2
- data/spec/unit/client_spec.rb +35 -3
- data/spec/unit/identifier_spec.rb +54 -15
- data/spec/unit/metadata_spec.rb +2 -0
- data/spec/unit/metadata_transform_datacite_spec.rb +169 -0
- metadata +54 -20
- data/.travis.yml +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6de69095537c80864a186b0089180182a74d08b2f6d9caddbab4628133919ef5
|
4
|
+
data.tar.gz: fefce462bfcb82b6297b5af267c3c9fe5bd49808675892634cf00df004ebd488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48ccd47fc68d90bcb867aee4a6880b1a9385cca28470611659d970db01e4a714538ff0f79268cbbcb4617ae6970e0a0c4ac9c640f283e1ed9d723d38d1a0d87d
|
7
|
+
data.tar.gz: 697963d59a8dff29f4da1d78c48eb54a2cf500900b56301a2f18f892067ee7624cb8d601aa2d07a91372b8a8f614e114254a8b820e9a9108754cc902fac2e6b8
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ develop ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ develop ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.6', '2.7']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
# uses: ruby/setup-ruby@v1
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rspec ./spec/unit/
|
data/README.md
CHANGED
@@ -33,9 +33,11 @@ Or install it yourself as:
|
|
33
33
|
>> identifier = Ezid::Identifier.mint("ark:/99999/fk4")
|
34
34
|
I, [2016-03-01T22:20:08.505323 #35148] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk4tq65d6k
|
35
35
|
=> #<Ezid::Identifier id=ark:/99999/fk4tq65d6k>
|
36
|
+
|
36
37
|
>> identifier.status
|
37
38
|
I, [2016-03-01T22:20:22.323650 #35148] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4tq65d6k
|
38
39
|
=> "public"
|
40
|
+
|
39
41
|
>> identifier.target
|
40
42
|
=> "http://ezid.cdlib.org/id/ark:/99999/fk4tq65d6k"
|
41
43
|
```
|
@@ -87,11 +89,14 @@ I, [2014-12-04T15:07:00.648676 #86655] INFO -- : EZID GetIdentifierMetadata --
|
|
87
89
|
```
|
88
90
|
>> identifier.target
|
89
91
|
=> "http://ezid.cdlib.org/id/ark:/99999/fk43f4wd4v"
|
92
|
+
|
90
93
|
>> identifier.target = "http://example.com"
|
91
94
|
=> "http://example.com"
|
95
|
+
|
92
96
|
>> identifier.save
|
93
97
|
I, [2014-12-09T11:24:26.321801 #32279] INFO -- : EZID ModifyIdentifier -- success: ark:/99999/fk43f4wd4v
|
94
98
|
=> #<Ezid::Identifier id="ark:/99999/fk43f4wd4v">
|
99
|
+
|
95
100
|
>> identifier.target
|
96
101
|
I, [2014-12-09T11:24:27.039288 #32279] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk43f4wd4v
|
97
102
|
=> "http://example.com"
|
@@ -107,6 +112,7 @@ I, [2014-12-09T11:24:27.039288 #32279] INFO -- : EZID GetIdentifierMetadata --
|
|
107
112
|
>> identifier = Ezid::Identifier.mint("ark:/99999/fk4", status: "reserved")
|
108
113
|
I, [2016-03-01T22:26:08.645858 #36701] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk4pz5fm1b
|
109
114
|
=> #<Ezid::Identifier id=ark:/99999/fk4pz5fm1b>
|
115
|
+
|
110
116
|
>> identifier.delete
|
111
117
|
I, [2016-03-01T22:26:14.829731 #36701] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4pz5fm1b
|
112
118
|
I, [2016-03-01T22:26:15.711390 #36701] INFO -- : EZID DeleteIdentifier -- success: ark:/99999/fk4pz5fm1b
|
@@ -120,22 +126,57 @@ See http://ezid.cdlib.org/doc/apidoc.html#parameters. Repeated values should be
|
|
120
126
|
*Added in v1.3.0:* `Ezid::BatchDownload` class.
|
121
127
|
|
122
128
|
```
|
123
|
-
>>
|
129
|
+
>> batch_download = Ezid::BatchDownload.new(:csv)
|
124
130
|
=> #<Ezid::BatchDownload format=:csv>
|
125
|
-
|
131
|
+
|
132
|
+
>> batch_download.column = ["_id", "_target"]
|
126
133
|
=> ["_id", "_target"]
|
127
|
-
|
134
|
+
|
135
|
+
>> batch_download.createdAfter = Date.today.to_time
|
128
136
|
=> 2016-02-24 00:00:00 -0500
|
129
|
-
|
137
|
+
|
138
|
+
>> batch_download
|
130
139
|
=> #<Ezid::BatchDownload column=["_id", "_target"] createdAfter=1456290000 format=:csv>
|
131
|
-
|
140
|
+
|
141
|
+
>> batch_download.url
|
132
142
|
I, [2016-02-24T18:03:40.828005 #1084] INFO -- : EZID BatchDownload -- success: http://ezid.cdlib.org/download/4a63401e17.csv.gz
|
133
143
|
=> "http://ezid.cdlib.org/download/4a63401e17.csv.gz"
|
134
|
-
|
135
|
-
|
136
|
-
=>
|
144
|
+
|
145
|
+
>> batch_download.file
|
146
|
+
=> /current/working/directory/4a63401e17.csv.gz
|
137
147
|
```
|
138
148
|
|
149
|
+
## Batch
|
150
|
+
|
151
|
+
*Added in v1.6.0.* `Ezid::Batch` class.
|
152
|
+
|
153
|
+
**Version 1.7.0 upgrade note:** This class was originally named `Ezid::BatchEnumerator`, but it is not a Ruby enumerator. `Ezid::Batch` is the new name with the same API.
|
154
|
+
|
155
|
+
```
|
156
|
+
>> require 'ezid/batch'
|
157
|
+
=> true
|
158
|
+
|
159
|
+
>> batch = Ezid::Batch.new(:anvl, "spec/fixtures/anvl_batch.txt")
|
160
|
+
=> #<Ezid::Batch:0x007f87a8900308 @format=:anvl, @batch_file="spec/fixtures/anvl_batch.txt">
|
161
|
+
|
162
|
+
>> id = batch.first
|
163
|
+
=> #<Ezid::Identifier id=ark:/99999/fk4086hs23>
|
164
|
+
|
165
|
+
>> id.target
|
166
|
+
=> "http://example.com"
|
167
|
+
|
168
|
+
>> puts id.metadata
|
169
|
+
_updated: 1488227717
|
170
|
+
_target: http://example.com
|
171
|
+
_profile: erc
|
172
|
+
_ownergroup: apitest
|
173
|
+
_owner: apitest
|
174
|
+
_export: yes
|
175
|
+
_created: 1488227717
|
176
|
+
_status: public
|
177
|
+
=> nil
|
178
|
+
```
|
179
|
+
|
139
180
|
## Metadata handling
|
140
181
|
|
141
182
|
Accessors are provided to ease the use of EZID [reserved metadata elements](http://ezid.cdlib.org/doc/apidoc.html#internal-metadata) and [metadata profiles](http://ezid.cdlib.org/doc/apidoc.html#metadata-profiles):
|
@@ -145,6 +186,7 @@ Accessors are provided to ease the use of EZID [reserved metadata elements](http
|
|
145
186
|
```
|
146
187
|
>> identifier.status # reads "_status" element
|
147
188
|
=> "public"
|
189
|
+
|
148
190
|
>> identifier.status = "unavailable" # writes "_status" element
|
149
191
|
=> "unavailable"
|
150
192
|
```
|
@@ -159,6 +201,7 @@ Notes:
|
|
159
201
|
```
|
160
202
|
>> identifier.dc_type # reads "dc.type" element
|
161
203
|
=> "Collection"
|
204
|
+
|
162
205
|
>> identifier.dc_type = "Image" # writes "dc.type" element
|
163
206
|
=> "Image"
|
164
207
|
```
|
@@ -253,11 +296,10 @@ require "ezid/test_helper"
|
|
253
296
|
|
254
297
|
The module provides constants:
|
255
298
|
|
256
|
-
- `
|
257
|
-
- `
|
258
|
-
- `
|
259
|
-
- `
|
260
|
-
- `TEST_PORT` => 443
|
299
|
+
- `EZID_TEST_SHOULDER` => "doi:10.5072/FK2"
|
300
|
+
- `EZID_TEST_USER` => "apitest"
|
301
|
+
- `EZID_TEST_HOST` => "ezid.cdlib.org"
|
302
|
+
- `EZID_TEST_PORT` => 443
|
261
303
|
|
262
304
|
The test user password is not provided - contact EZID and configure as above - or use your own EZID credentials, since all accounts can mint/create on the test shoulders.
|
263
305
|
|
@@ -283,3 +325,7 @@ In order to run the integration tests successfully, you must supply the password
|
|
283
325
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
284
326
|
4. Push to the branch (`git push origin my-new-feature`)
|
285
327
|
5. Create a new Pull Request
|
328
|
+
|
329
|
+
## Acknowledgments
|
330
|
+
|
331
|
+
- Justin Gondron (jgondron) contributed Datacite compatibility code (added in v1.8.0).
|
data/Rakefile
CHANGED
@@ -5,18 +5,18 @@ desc "Run all specs in spec directory"
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
6
|
|
7
7
|
desc "Run the ci build (no integration tests)"
|
8
|
-
|
9
|
-
|
8
|
+
RSpec::Core::RakeTask.new(:ci) do |t|
|
9
|
+
t.rspec_opts = "--tag '~deprecated' --tag '~ezid'"
|
10
10
|
end
|
11
11
|
|
12
12
|
desc "Run tests of deprecated functionality"
|
13
|
-
|
14
|
-
|
13
|
+
RSpec::Core::RakeTask.new(:deprecated) do |t|
|
14
|
+
t.rspec_opts = "--tag deprecated"
|
15
15
|
end
|
16
16
|
|
17
17
|
desc "Run the integration tests"
|
18
|
-
|
19
|
-
|
18
|
+
RSpec::Core::RakeTask.new(:integration) do |t|
|
19
|
+
t.rspec_opts = "--tag integration"
|
20
20
|
end
|
21
21
|
|
22
22
|
task default: :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.9.0
|
data/ezid-client.gemspec
CHANGED
@@ -17,12 +17,14 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.required_ruby_version = "~> 2.
|
20
|
+
spec.required_ruby_version = "~> 2.1"
|
21
21
|
|
22
22
|
spec.add_dependency "hashie", "~> 3.4", ">= 3.4.3"
|
23
|
+
spec.add_dependency "nokogiri"
|
23
24
|
|
24
|
-
spec.add_development_dependency "bundler"
|
25
|
-
spec.add_development_dependency "
|
25
|
+
spec.add_development_dependency "bundler"
|
26
|
+
spec.add_development_dependency "byebug"
|
27
|
+
spec.add_development_dependency "rake"
|
26
28
|
spec.add_development_dependency "rspec", "~> 3.4"
|
27
29
|
spec.add_development_dependency "rspec-its", "~> 1.2"
|
28
30
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Ezid
|
2
|
-
class
|
2
|
+
class Batch
|
3
3
|
include Enumerable
|
4
4
|
|
5
5
|
attr_reader :format, :batch_file
|
@@ -25,7 +25,7 @@ module Ezid
|
|
25
25
|
while record = f.gets("")
|
26
26
|
head, metadata = record.split(/\n/, 2)
|
27
27
|
id = head.sub(/\A::/, "").strip
|
28
|
-
yield
|
28
|
+
yield Identifier.load(id, metadata)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/ezid/batch_download.rb
CHANGED
@@ -84,6 +84,8 @@ module Ezid
|
|
84
84
|
get_response.download_url
|
85
85
|
end
|
86
86
|
|
87
|
+
alias_method :url, :download_url
|
88
|
+
|
87
89
|
def download_file(path: nil)
|
88
90
|
path ||= Dir.getwd
|
89
91
|
fullpath = File.directory?(path) ? File.join(path, download_filename) : path
|
@@ -123,6 +125,8 @@ module Ezid
|
|
123
125
|
fullpath
|
124
126
|
end
|
125
127
|
|
128
|
+
alias_method :file, :download_file
|
129
|
+
|
126
130
|
private
|
127
131
|
|
128
132
|
def download_uri
|
data/lib/ezid/client.rb
CHANGED
@@ -44,12 +44,11 @@ module Ezid
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
attr_reader :user, :password, :host, :port, :
|
47
|
+
attr_reader :user, :password, :host, :port, :timeout
|
48
48
|
|
49
49
|
def initialize(opts = {})
|
50
50
|
@host = opts[:host] || config.host
|
51
51
|
@port = (opts[:port] || config.port).to_i
|
52
|
-
@use_ssl = opts[:use_ssl] || config.use_ssl
|
53
52
|
@timeout = (opts[:timeout] || config.timeout).to_i
|
54
53
|
@user = opts[:user] || config.user
|
55
54
|
@password = opts[:password] || config.password
|
@@ -60,6 +59,12 @@ module Ezid
|
|
60
59
|
end
|
61
60
|
end
|
62
61
|
|
62
|
+
def use_ssl
|
63
|
+
warn "[DEPRECATION] `use_ssl` is deprecated and will be removed in ezid-client v2.0." \
|
64
|
+
" EZID requires SSL as of April 30, 2017."
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
63
68
|
def inspect
|
64
69
|
"#<#{self.class.name} connection=#{connection.inspect}, " \
|
65
70
|
"user=#{user.inspect}, session=#{logged_in? ? 'OPEN' : 'CLOSED'}>"
|
@@ -188,15 +193,11 @@ module Ezid
|
|
188
193
|
|
189
194
|
private
|
190
195
|
|
191
|
-
def use_ssl?
|
192
|
-
use_ssl || port == 443
|
193
|
-
end
|
194
|
-
|
195
196
|
def build_connection
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
197
|
+
Net::HTTP.new(host, port).tap do |conn|
|
198
|
+
conn.use_ssl = true
|
199
|
+
conn.read_timeout = timeout
|
200
|
+
end
|
200
201
|
end
|
201
202
|
|
202
203
|
def handle_response(response, request_name)
|
data/lib/ezid/configuration.rb
CHANGED
@@ -20,9 +20,6 @@ module Ezid
|
|
20
20
|
# EZID TCP/IP port
|
21
21
|
attr_accessor :port
|
22
22
|
|
23
|
-
# Use HTTPS?
|
24
|
-
attr_accessor :use_ssl
|
25
|
-
|
26
23
|
# HTTP read timeout (seconds)
|
27
24
|
attr_accessor :timeout
|
28
25
|
|
@@ -44,7 +41,6 @@ module Ezid
|
|
44
41
|
@password = ENV["EZID_PASSWORD"]
|
45
42
|
@host = ENV["EZID_HOST"] || HOST
|
46
43
|
@port = ENV["EZID_PORT"] || PORT
|
47
|
-
@use_ssl = true if ENV["EZID_USE_SSL"] == true.to_s
|
48
44
|
@timeout = ENV["EZID_TIMEOUT"] || TIMEOUT
|
49
45
|
@default_shoulder = ENV["EZID_DEFAULT_SHOULDER"]
|
50
46
|
end
|
@@ -67,5 +63,16 @@ module Ezid
|
|
67
63
|
Metadata
|
68
64
|
end
|
69
65
|
|
66
|
+
def use_ssl
|
67
|
+
warn "[DEPRECATION] `use_ssl` is deprecated and will be removed in ezid-client v2.0." \
|
68
|
+
" EZID requires SSL as of April 30, 2017."
|
69
|
+
true
|
70
|
+
end
|
71
|
+
|
72
|
+
def use_ssl=(*)
|
73
|
+
warn "[DEPRECATION] `use_ssl=` is deprecated and will be removed in ezid-client v2.0." \
|
74
|
+
" EZID requires SSL as of April 30, 2017."
|
75
|
+
end
|
76
|
+
|
70
77
|
end
|
71
78
|
end
|
data/lib/ezid/error.rb
CHANGED
data/lib/ezid/identifier.rb
CHANGED
@@ -65,10 +65,25 @@ module Ezid
|
|
65
65
|
# @return [Ezid::Identifier] the identifier
|
66
66
|
# @raise [Ezid::IdentifierNotFoundError]
|
67
67
|
def modify(id, metadata)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
allocate.tap do |i|
|
69
|
+
i.id = id
|
70
|
+
i.update_metadata(metadata)
|
71
|
+
i.modify!
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Loads an identifier with provided remote metadata
|
76
|
+
# The main purpose is to provide an API in a batch processing
|
77
|
+
# context to instantiate Identifiers from a BatchDownload.
|
78
|
+
# @see #load_metadata!
|
79
|
+
# @param id [String] the EZID identifier
|
80
|
+
# @param metadata [String, Hash, Ezid::Metadata] the provided metadata
|
81
|
+
# @return [Ezid::Identifier] the identifier
|
82
|
+
def load(id, metadata = nil)
|
83
|
+
allocate.tap do |i|
|
84
|
+
i.id = id
|
85
|
+
i.load_metadata!(metadata)
|
86
|
+
end
|
72
87
|
end
|
73
88
|
|
74
89
|
# Retrieves an identifier
|
@@ -76,9 +91,10 @@ module Ezid
|
|
76
91
|
# @return [Ezid::Identifier] the identifier
|
77
92
|
# @raise [Ezid::IdentifierNotFoundError] if the identifier does not exist in EZID
|
78
93
|
def find(id)
|
79
|
-
|
80
|
-
|
81
|
-
|
94
|
+
allocate.tap do |i|
|
95
|
+
i.id = id
|
96
|
+
i.load_metadata
|
97
|
+
end
|
82
98
|
end
|
83
99
|
end
|
84
100
|
|
@@ -132,9 +148,14 @@ module Ezid
|
|
132
148
|
# @return [Ezid::Metadata] the metadata
|
133
149
|
def metadata(_=nil)
|
134
150
|
if !_.nil?
|
135
|
-
warn "[DEPRECATION] The parameter of `metadata` is
|
151
|
+
warn "[DEPRECATION] The parameter of `metadata` is ignored and will be removed in 2.0. " \
|
152
|
+
"(called from #{caller.first})"
|
136
153
|
end
|
137
|
-
|
154
|
+
remote_metadata.merge(local_metadata).freeze
|
155
|
+
end
|
156
|
+
|
157
|
+
def local_metadata
|
158
|
+
@local_metadata ||= Metadata.new
|
138
159
|
end
|
139
160
|
|
140
161
|
def remote_metadata
|
@@ -172,7 +193,7 @@ module Ezid
|
|
172
193
|
# @param attrs [Hash] the metadata
|
173
194
|
# @return [Ezid::Identifier] the identifier
|
174
195
|
def update_metadata(attrs={})
|
175
|
-
|
196
|
+
local_metadata.update(attrs)
|
176
197
|
self
|
177
198
|
end
|
178
199
|
|
@@ -203,13 +224,25 @@ module Ezid
|
|
203
224
|
load_metadata
|
204
225
|
end
|
205
226
|
|
206
|
-
# Loads the metadata from EZID
|
227
|
+
# Loads the metadata from EZID and marks the identifier as persisted.
|
207
228
|
# @return [Ezid::Identifier] the identifier
|
208
|
-
# @raise [Ezid::Error]
|
229
|
+
# @raise [Ezid::Error] the identifier is not found or other error.
|
209
230
|
def load_metadata
|
210
231
|
response = client.get_identifier_metadata(id)
|
211
|
-
|
212
|
-
|
232
|
+
load_remote_metadata(response.metadata)
|
233
|
+
persists!
|
234
|
+
self
|
235
|
+
end
|
236
|
+
|
237
|
+
# Loads provided metadata and marks the identifier as persisted.
|
238
|
+
# The main purpose is to provide an API in a batch processing
|
239
|
+
# context to instantiate Identifiers from a BatchDownload.
|
240
|
+
# @see Ezid::BatchEnumerator
|
241
|
+
# @see .load
|
242
|
+
# @param metadata [String, Hash, Ezid::Metadata] the provided metadata
|
243
|
+
# @return [Ezid::Identifier] the identifier
|
244
|
+
def load_metadata!(metadata)
|
245
|
+
load_remote_metadata(metadata)
|
213
246
|
persists!
|
214
247
|
self
|
215
248
|
end
|
@@ -287,8 +320,8 @@ module Ezid
|
|
287
320
|
end
|
288
321
|
|
289
322
|
def reset_metadata
|
290
|
-
|
291
|
-
remote_metadata.clear
|
323
|
+
local_metadata.clear
|
324
|
+
remote_metadata.clear
|
292
325
|
end
|
293
326
|
|
294
327
|
protected
|
@@ -302,7 +335,7 @@ module Ezid
|
|
302
335
|
private
|
303
336
|
|
304
337
|
def local_or_remote_metadata(*args)
|
305
|
-
value =
|
338
|
+
value = local_metadata.send(*args)
|
306
339
|
if value.nil? && persisted?
|
307
340
|
load_metadata if remote_metadata.empty?
|
308
341
|
value = remote_metadata.send(*args)
|
@@ -311,7 +344,7 @@ module Ezid
|
|
311
344
|
end
|
312
345
|
|
313
346
|
def modify
|
314
|
-
client.modify_identifier(id,
|
347
|
+
client.modify_identifier(id, local_metadata)
|
315
348
|
end
|
316
349
|
|
317
350
|
def create_or_mint
|
@@ -319,12 +352,12 @@ module Ezid
|
|
319
352
|
end
|
320
353
|
|
321
354
|
def mint
|
322
|
-
response = client.mint_identifier(shoulder,
|
355
|
+
response = client.mint_identifier(shoulder, local_metadata)
|
323
356
|
self.id = response.id
|
324
357
|
end
|
325
358
|
|
326
359
|
def create
|
327
|
-
client.create_identifier(id,
|
360
|
+
client.create_identifier(id, local_metadata)
|
328
361
|
end
|
329
362
|
|
330
363
|
def persist
|
@@ -340,5 +373,9 @@ module Ezid
|
|
340
373
|
update_metadata(self.class.defaults)
|
341
374
|
end
|
342
375
|
|
376
|
+
def load_remote_metadata(metadata)
|
377
|
+
remote_metadata.replace(metadata)
|
378
|
+
end
|
379
|
+
|
343
380
|
end
|
344
381
|
end
|