ezid-client 0.13.0 → 1.0.0

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: a879db606f554ad22f27d2a94de3ea22b13b4b45
4
- data.tar.gz: cbf0e449920590e6c7e5bbf83fade23fca94a474
3
+ metadata.gz: 67d7c521805d41988bf36686a34d9b5fff22564e
4
+ data.tar.gz: f2d7863a870a77a0c4fd34a434d25813c135ee15
5
5
  SHA512:
6
- metadata.gz: f4edff18cfd3337b0445ea6aa57fcaa43cdfaa70c0f2538c8df63feb37901f51b155b45039849359bbff5cd0c574183a5efb521102f15f145b643c5b77a22085
7
- data.tar.gz: 70325ab88f390c26180dc130b7862f4b0b6e70584c4178e8c707f8c2a9ae78f098fc06b4e6eb37225ddc1f650d36760e0364d8ea938f2a258e57adebe3cf1ca7
6
+ metadata.gz: d10753b4d6bfb1fc31825dd62bc680da20b6772f2313ae5309b3df4c93f98b99ba3b72aca0b323961fbd3c8b09f035843cae73c966619a958a35e1deb6a96dfd
7
+ data.tar.gz: ef0073723387486a9e531227bc83e4ea7b2998337f5beed74a7bb7b00034ada6bf437b0595142e2ff0797e9b189f54fd26411376f1ef480a35ea654a2ca83818
data/README.md CHANGED
@@ -145,7 +145,7 @@ Accessors are provided to ease the use of EZID [reserved metadata elements](http
145
145
  Notes:
146
146
  - `_crossref` is an exception because `crossref` is also the name of a metadata profile and a special element. Use `identifier._crossref` to read and `identifier._crossref = value` to write.
147
147
  - Reserved elements which are not user-writeable do not implement writers.
148
- - Special readers are implemented for reserved elements having date/time values -- `_created` and `_updated` -- which convert the string time values of EZID to Ruby `Time` instances.
148
+ - Special readers are implemented for reserved elements having date/time values (`_created` and `_updated`) which convert the string time values of EZID to Ruby `Time` instances.
149
149
 
150
150
  **Metadata profile elements** can be read and written using the name of the element, replacing the dot (".") with an underscore:
151
151
 
@@ -156,18 +156,7 @@ Notes:
156
156
  => "Image"
157
157
  ```
158
158
 
159
- **Registering custom metadata elements**
160
-
161
- Custom metadata element accessors can be created by a registration process:
162
-
163
- ```ruby
164
- Ezid::Client.configure do |config|
165
- # register the element "custom"
166
- config.metadata.register_element :custom
167
- # register the element "dc.identifier" under the accessor :dc_identifier
168
- config.metadata.register_element :dc_identifier, name: "dc.identifier"
169
- end
170
- ```
159
+ Accessors are also implemented for the `crossref`, `datacite`, and `erc` elements as described in the EZID API documentation.
171
160
 
172
161
  **Setting default metadata values**
173
162
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.0
1
+ 1.0.0
data/lib/ezid/metadata.rb CHANGED
@@ -7,6 +7,39 @@ module Ezid
7
7
  # @api private
8
8
  #
9
9
  class Metadata < SimpleDelegator
10
+
11
+ class << self
12
+ def metadata_reader(method, alias_as=nil)
13
+ define_method method do
14
+ self[method.to_s]
15
+ end
16
+ if alias_as
17
+ alias_method alias_as, method
18
+ end
19
+ end
20
+
21
+ def metadata_writer(method, alias_as=nil)
22
+ define_method "#{method}=" do |value|
23
+ self[method.to_s] = value
24
+ end
25
+ if alias_as
26
+ alias_method "#{alias_as}=".to_sym, "#{method}=".to_sym
27
+ end
28
+ end
29
+
30
+ def metadata_accessor(method, alias_as=nil)
31
+ metadata_reader method, alias_as
32
+ metadata_writer method, alias_as
33
+ end
34
+
35
+ def metadata_profile(profile, *methods)
36
+ methods.each do |method|
37
+ element = [profile, method].join(".")
38
+ alias_as = [profile, method].join("_")
39
+ metadata_accessor element, alias_as
40
+ end
41
+ end
42
+ end
10
43
 
11
44
  # EZID metadata field/value separator
12
45
  ANVL_SEPARATOR = ": "
@@ -34,195 +67,97 @@ module Ezid
34
67
  # A line ending
35
68
  LINE_ENDING_RE = /\r?\n/
36
69
 
37
- # A metadata element
38
- Element = Struct.new(:name, :reader, :writer)
39
-
40
- # Metadata profiles
41
- PROFILES = {
42
- "dc" => %w( creator title publisher date type ).freeze,
43
- "datacite" => %w( creator title publisher publicationyear resourcetype ).freeze,
44
- "erc" => %w( who what when ).freeze,
45
- "crossref" => [].freeze
46
- }.freeze
47
-
48
- # EZID reserved metadata elements that have time values
49
- # @see http://ezid.cdlib.org/doc/apidoc.html#internal-metadata
50
- RESERVED_TIME_ELEMENTS = %w( _created _updated )
51
-
52
70
  # EZID reserved metadata elements that are read-only
53
71
  # @see http://ezid.cdlib.org/doc/apidoc.html#internal-metadata
54
- RESERVED_READONLY_ELEMENTS = %w( _owner _ownergroup _shadows _shadowedby _datacenter _created _updated )
55
-
56
- # EZID reserved metadata elements that may be set by clients
57
- # @see http://ezid.cdlib.org/doc/apidoc.html#internal-metadata
58
- RESERVED_READWRITE_ELEMENTS = %w( _coowners _target _profile _status _export _crossref )
59
-
60
- # All EZID reserved metadata elements
61
- # @see http://ezid.cdlib.org/doc/apidoc.html#internal-metadata
62
- RESERVED_ELEMENTS = RESERVED_READONLY_ELEMENTS + RESERVED_READWRITE_ELEMENTS
63
-
64
- def self.initialize!
65
- register_elements
66
- end
67
-
68
- def self.registered_elements
69
- @@registered_elements ||= {}
70
- end
71
-
72
- def self.register_elements
73
- register_profile_elements
74
- register_reserved_elements
75
- end
76
-
77
- def self.register_element(accessor, opts={})
78
- if element = registered_elements[accessor.to_sym]
79
- raise Error, "Element \"#{element.name}\" is registered under the accessor :#{accessor}."
80
- end
81
- element = Element.new(opts.fetch(:name, accessor.to_s))
82
- element.reader = define_reader(accessor, element.name)
83
- element.writer = define_writer(accessor, element.name) if opts.fetch(:writer, true)
84
- registered_elements[accessor.to_sym] = element
85
- end
86
-
87
- def self.unregister_element(accessor)
88
- element = registered_elements.delete(accessor)
89
- raise Error, "No element is registered under the accessor :#{accessor}." unless element
90
- remove_method(element.reader)
91
- remove_method(element.writer) if element.writer
92
- end
93
-
94
- def self.register_profile_element(profile, element)
95
- register_element("#{profile}_#{element}", name: "#{profile}.#{element}")
96
- end
97
-
98
- def self.register_profile_elements(profile = nil)
99
- if profile
100
- PROFILES[profile].each { |element| register_profile_element(profile, element) }
101
- else
102
- PROFILES.keys.each do |profile|
103
- register_profile_elements(profile)
104
- register_element(profile) unless profile == "dc"
105
- end
106
- end
107
- end
72
+ READONLY = %w( _owner _ownergroup _shadows _shadowedby _datacenter _created _updated )
73
+
74
+ metadata_accessor :_coowners, :coowners
75
+ metadata_accessor :_crossref
76
+ metadata_accessor :_export, :export
77
+ metadata_accessor :_profile, :profile
78
+ metadata_accessor :_status, :status
79
+ metadata_accessor :_target, :target
80
+
81
+ metadata_accessor :crossref
82
+ metadata_accessor :datacite
83
+ metadata_accessor :erc
84
+
85
+ metadata_reader :_created
86
+ metadata_reader :_datacenter, :datacenter
87
+ metadata_reader :_owner, :owner
88
+ metadata_reader :_ownergroup, :ownergroup
89
+ metadata_reader :_shadowedby, :shadowedby
90
+ metadata_reader :_shadows, :shadows
91
+ metadata_reader :_updated
92
+
93
+ metadata_profile :dc, :creator, :title, :publisher, :date, :type
94
+ metadata_profile :datacite, :creator, :title, :publisher, :publicationyear, :resourcetype
95
+ metadata_profile :erc, :who, :what, :when
108
96
 
109
- def self.register_reserved_elements
110
- RESERVED_ELEMENTS.each do |element|
111
- accessor = (element == "_crossref") ? element : element.sub("_", "")
112
- register_element(accessor, name: element, writer: RESERVED_READWRITE_ELEMENTS.include?(element))
113
- end
97
+ def initialize(data={})
98
+ super coerce(data)
114
99
  end
115
100
 
116
- def self.define_reader(accessor, element)
117
- define_method(accessor) do
118
- reader(element)
119
- end
101
+ def created
102
+ to_time _created
120
103
  end
121
104
 
122
- def self.define_writer(accessor, element)
123
- define_method("#{accessor}=") do |value|
124
- writer(element, value)
125
- end
126
- end
127
-
128
- private_class_method :register_elements,
129
- :register_reserved_elements,
130
- :register_profile_elements,
131
- :unregister_element,
132
- :define_reader,
133
- :define_writer
134
-
135
- def initialize(data={})
136
- super(coerce(data))
105
+ def updated
106
+ to_time _updated
137
107
  end
138
108
 
139
109
  # Output metadata in EZID ANVL format
140
110
  # @see http://ezid.cdlib.org/doc/apidoc.html#request-response-bodies
141
111
  # @return [String] the ANVL output
142
112
  def to_anvl(include_readonly = true)
143
- elements = __getobj__.dup # copy, don't modify!
144
- elements.reject! { |k, v| RESERVED_READONLY_ELEMENTS.include?(k) } unless include_readonly
145
- escape_elements(elements).map { |e| e.join(ANVL_SEPARATOR) }.join("\n")
113
+ hsh = __getobj__.dup
114
+ hsh.reject! { |k, v| READONLY.include?(k) } unless include_readonly
115
+ elements = hsh.map do |name, value|
116
+ element = [escape(ESCAPE_NAMES_RE, name), escape(ESCAPE_VALUES_RE, value)]
117
+ element.join(ANVL_SEPARATOR)
118
+ end
119
+ elements.join("\n").force_encoding(Encoding::UTF_8)
146
120
  end
147
121
 
148
122
  def to_s
149
123
  to_anvl
150
124
  end
151
125
 
152
- def registered_elements
153
- self.class.registered_elements
154
- end
155
-
156
126
  private
157
127
 
158
- def reader(element)
159
- value = self[element]
160
- if RESERVED_TIME_ELEMENTS.include?(element)
161
- time = value.to_i
162
- value = (time == 0) ? nil : Time.at(time).utc
163
- end
164
- value
165
- end
166
-
167
- def writer(element, value)
168
- self[element] = value
169
- end
170
-
171
- # Coerce data into a Hash of elements
172
- def coerce(data)
173
- data.to_h
174
- rescue NoMethodError
175
- coerce_string(data)
176
- end
177
-
178
- # Escape elements hash keys and values
179
- def escape_elements(hsh)
180
- hsh.each_with_object({}) do |(n, v), memo|
181
- memo[escape_name(n)] = escape_value(v)
182
- end
183
- end
184
-
185
- # Escape an element name
186
- def escape_name(n)
187
- escape(ESCAPE_NAMES_RE, n)
188
- end
128
+ def to_time(value)
129
+ time = value.to_i
130
+ (time == 0) ? nil : Time.at(time).utc
131
+ end
189
132
 
190
- # Escape an element value
191
- def escape_value(v)
192
- escape(ESCAPE_VALUES_RE, v)
193
- end
133
+ # Coerce data into a Hash of elements
134
+ def coerce(data)
135
+ data.to_h
136
+ rescue NoMethodError
137
+ coerce_string(data)
138
+ end
194
139
 
195
- # Escape string for sending to EZID host
196
- # @see http://ezid.cdlib.org/doc/apidoc.html#request-response-bodies
197
- # @param re [Regexp] the regular expression to match for escaping
198
- # @param s [String] the string to escape
199
- # @return [String] the escaped string
200
- def escape(re, s)
201
- s.gsub(re) { |m| URI.encode_www_form_component(m.force_encoding(Encoding::UTF_8)) }
202
- end
140
+ # Escape string for sending to EZID host
141
+ def escape(regexp, value)
142
+ value.gsub(regexp) { |m| URI.encode_www_form_component(m.force_encoding(Encoding::UTF_8)) }
143
+ end
203
144
 
204
- # Unescape value from EZID host (or other source)
205
- # @see http://ezid.cdlib.org/doc/apidoc.html#request-response-bodies
206
- # @param value [String] the value to unescape
207
- # @return [String] the unescaped value
208
- def unescape(value)
209
- value.gsub(UNESCAPE_RE) { |m| URI.decode_www_form_component(m) }
210
- end
145
+ # Unescape value from EZID host (or other source)
146
+ def unescape(value)
147
+ value.gsub(UNESCAPE_RE) { |m| URI.decode_www_form_component(m) }
148
+ end
211
149
 
212
- # Coerce a string of metadata (e.g., from EZID host) into a Hash
213
- # @note EZID host does not send comments or line continuations.
214
- # @param data [String] the string to coerce
215
- # @return [Hash] the hash of coerced data
216
- def coerce_string(data)
217
- data.gsub!(COMMENT_RE, "")
218
- data.gsub!(LINE_CONTINUATION_RE, " ")
219
- data.split(LINE_ENDING_RE).each_with_object({}) do |line, memo|
220
- element, value = line.split(ANVL_SEPARATOR, 2)
221
- memo[unescape(element.strip)] = unescape(value.strip)
222
- end
150
+ # Coerce a string of metadata (e.g., from EZID host) into a Hash
151
+ # @note EZID host does not send comments or line continuations.
152
+ def coerce_string(data)
153
+ data.gsub!(COMMENT_RE, "")
154
+ data.gsub!(LINE_CONTINUATION_RE, " ")
155
+ data.split(LINE_ENDING_RE).each_with_object({}) do |line, memo|
156
+ element, value = line.split(ANVL_SEPARATOR, 2)
157
+ memo[unescape(element.strip)] = unescape(value.strip)
223
158
  end
159
+ end
224
160
 
225
161
  end
226
162
  end
227
163
 
228
- Ezid::Metadata.initialize!
@@ -7,14 +7,8 @@ module Ezid
7
7
  self.path = "/download_request"
8
8
  self.response_class = BatchDownloadResponse
9
9
 
10
- attr_reader :params
11
-
12
10
  def initialize(client, params={})
13
- @params = params
14
11
  super
15
- end
16
-
17
- def customize_request
18
12
  set_form_data(params)
19
13
  end
20
14
 
@@ -42,7 +42,7 @@ module Ezid
42
42
  def initialize(client, *args)
43
43
  @client = client
44
44
  super build_request
45
- customize_request
45
+ set_content_type("text/plain", charset: "UTF-8")
46
46
  end
47
47
 
48
48
  # Executes the request and returns the response
@@ -97,10 +97,6 @@ module Ezid
97
97
  end
98
98
  end
99
99
 
100
- def customize_request
101
- set_content_type("text/plain", charset: "UTF-8")
102
- end
103
-
104
100
  def build_request
105
101
  self.class.http_method.new(uri)
106
102
  end
@@ -150,7 +150,7 @@ module Ezid
150
150
  allow(subject).to receive(:persisted?) { true }
151
151
  end
152
152
  it "should modify the identifier" do
153
- expect(subject.client).to receive(:modify_identifier).with("id", {}) { double(id: "id") }
153
+ expect(subject.client).to receive(:modify_identifier).with("id", subject.metadata) { double(id: "id") }
154
154
  subject.save
155
155
  end
156
156
  end
@@ -161,7 +161,7 @@ module Ezid
161
161
  context "and `id' is present" do
162
162
  before { allow(subject).to receive(:id) { "id" } }
163
163
  it "should create the identifier" do
164
- expect(subject.client).to receive(:create_identifier).with("id", {}) { double(id: "id") }
164
+ expect(subject.client).to receive(:create_identifier).with("id", subject.metadata) { double(id: "id") }
165
165
  subject.save
166
166
  end
167
167
  end
@@ -169,7 +169,7 @@ module Ezid
169
169
  context "and `shoulder' is present" do
170
170
  before { allow(subject).to receive(:shoulder) { TEST_ARK_SHOULDER } }
171
171
  it "should mint the identifier" do
172
- expect(subject.client).to receive(:mint_identifier).with(TEST_ARK_SHOULDER, {}) { double(id: "id") }
172
+ expect(subject.client).to receive(:mint_identifier).with(TEST_ARK_SHOULDER, subject.metadata) { double(id: "id") }
173
173
  subject.save
174
174
  end
175
175
  end
@@ -1,82 +1,152 @@
1
1
  module Ezid
2
2
  RSpec.describe Metadata do
3
3
 
4
- describe "reserved elements" do
5
- describe "readers" do
6
- Metadata::RESERVED_ELEMENTS.each do |element|
7
- it "should have a reader for '#{element}'" do
8
- expect(subject).to receive(:reader).with(element)
9
- reader = (element == "_crossref") ? element : element.sub("_", "")
10
- subject.send(reader)
11
- end
4
+ describe "metadata accessors and aliases" do
5
+ shared_examples "a metadata writer" do |writer|
6
+ it "writes the \"#{writer}\" element" do
7
+ subject.send("#{writer}=", "value")
8
+ expect(subject[writer.to_s]).to eq("value")
12
9
  end
13
- describe "for time-based elements" do
14
- Metadata::RESERVED_TIME_ELEMENTS.each do |element|
15
- context "\"#{element}\"" do
16
- before { subject[element] = "1416507086" }
17
- it "should have a reader than returns a Time instance" do
18
- expect(subject).to receive(:reader).with(element).and_call_original
19
- expect(subject.send(element.sub("_", ""))).to eq(Time.parse("2014-11-20 13:11:26 -0500"))
20
- end
21
- end
22
- end
10
+ end
11
+
12
+ shared_examples "a metadata reader" do |reader|
13
+ it "reads the \"#{reader}\" element" do
14
+ subject[reader.to_s] = "value"
15
+ expect(subject.send(reader)).to eq("value")
23
16
  end
24
17
  end
25
- describe "writers" do
26
- Metadata::RESERVED_READWRITE_ELEMENTS.each do |element|
27
- next if element == "_crossref"
28
- it "should have a writer for '#{element}'" do
29
- expect(subject).to receive(:writer).with(element, "value")
30
- writer = ((element == "_crossref") ? element : element.sub("_", "")).concat("=")
31
- subject.send(writer, "value")
32
- end
18
+
19
+ shared_examples "a metadata reader with an alias" do |reader, aliased_as|
20
+ it_behaves_like "a metadata reader", reader
21
+ it "has a reader alias \"#{aliased_as}\"" do
22
+ subject[reader.to_s] = "value"
23
+ expect(subject.send(aliased_as)).to eq("value")
24
+ end
25
+ end
26
+
27
+ shared_examples "a metadata writer with an alias" do |writer, aliased_as|
28
+ it_behaves_like "a metadata writer", writer
29
+ it "has a writer alias \"#{aliased_as}\"" do
30
+ subject.send("#{aliased_as}=", "value")
31
+ expect(subject.send(writer)).to eq("value")
33
32
  end
34
33
  end
35
- end
36
34
 
37
- describe "metadata profiles" do
38
- Metadata::PROFILES.each do |profile, elements|
39
- describe "the '#{profile}' metadata profile" do
40
- describe "readers" do
41
- elements.each do |element|
42
- it "should have a reader for '#{profile}.#{element}'" do
43
- expect(subject).to receive(:reader).with("#{profile}.#{element}")
44
- subject.send("#{profile}_#{element}")
45
- end
46
- end
47
- end
48
- describe "writers" do
49
- elements.each do |element|
50
- it "should have a writer for '#{profile}.#{element}'" do
51
- expect(subject).to receive(:writer).with("#{profile}.#{element}", "value")
52
- subject.send("#{profile}_#{element}=", "value")
53
- end
54
- end
55
- end
56
- next if profile == "dc"
57
- it "should have a reader for '#{profile}'" do
58
- expect(subject).to receive(:reader).with(profile)
59
- subject.send(profile)
60
- end
61
- it "should have a writer for '#{profile}'" do
62
- expect(subject).to receive(:writer).with(profile, "value")
63
- subject.send("#{profile}=", "value")
64
- end
35
+ shared_examples "a metadata accessor" do |accessor|
36
+ it_behaves_like "a metadata reader", accessor
37
+ it_behaves_like "a metadata writer", accessor
38
+ end
39
+
40
+ shared_examples "a metadata accessor with an alias" do |accessor, aliased_as|
41
+ it_behaves_like "a metadata reader with an alias", accessor, aliased_as
42
+ it_behaves_like "a metadata writer with an alias", accessor, aliased_as
43
+ end
44
+
45
+ shared_examples "a time reader alias" do |element, aliased_as|
46
+ before { subject[element.to_s] = "1416507086" }
47
+ it "should return the Time value for the element" do
48
+ expect(subject.send(aliased_as)).to eq(Time.parse("2014-11-20 13:11:26 -0500"))
65
49
  end
66
50
  end
67
- end
68
51
 
69
- describe "custom element" do
70
- let(:element) { Metadata::Element.new("custom", true) }
71
- before { described_class.register_element :custom }
72
- after { described_class.send(:unregister_element, :custom) }
73
- it "should have a reader" do
74
- expect(subject).to receive(:reader).with("custom")
75
- subject.custom
76
- end
77
- it "should have a writer" do
78
- expect(subject).to receive(:writer).with("custom", "value")
79
- subject.custom = "value"
52
+ shared_examples "a metadata profile accessor with an alias" do |profile, accessor|
53
+ it_behaves_like "a metadata accessor with an alias", [profile, accessor].join("."), [profile, accessor].join("_")
54
+ end
55
+
56
+ describe "_owner" do
57
+ it_behaves_like "a metadata reader with an alias", :_owner, :owner
58
+ end
59
+ describe "_ownergroup" do
60
+ it_behaves_like "a metadata reader with an alias", :_ownergroup, :ownergroup
61
+ end
62
+ describe "_shadows" do
63
+ it_behaves_like "a metadata reader with an alias", :_shadows, :shadows
64
+ end
65
+ describe "_shadowedby" do
66
+ it_behaves_like "a metadata reader with an alias", :_shadowedby, :shadowedby
67
+ end
68
+ describe "_datacenter" do
69
+ it_behaves_like "a metadata reader with an alias", :_datacenter, :datacenter
70
+ end
71
+
72
+ describe "_coowners" do
73
+ it_behaves_like "a metadata accessor with an alias", :_coowners, :coowners
74
+ end
75
+ describe "_target" do
76
+ it_behaves_like "a metadata accessor with an alias", :_target, :target
77
+ end
78
+ describe "_profile" do
79
+ it_behaves_like "a metadata accessor with an alias", :_profile, :profile
80
+ end
81
+ describe "_status" do
82
+ it_behaves_like "a metadata accessor with an alias", :_status, :status
83
+ end
84
+ describe "_export" do
85
+ it_behaves_like "a metadata accessor with an alias", :_export, :export
86
+ end
87
+
88
+ describe "_created" do
89
+ it_behaves_like "a metadata reader", :_created
90
+ it_behaves_like "a time reader alias", :_created, :created
91
+ end
92
+ describe "_updated" do
93
+ it_behaves_like "a metadata reader", :_updated
94
+ it_behaves_like "a time reader alias", :_updated, :updated
95
+ end
96
+
97
+ describe "erc" do
98
+ it_behaves_like "a metadata accessor", :erc
99
+ end
100
+ describe "datacite" do
101
+ it_behaves_like "a metadata accessor", :datacite
102
+ end
103
+ describe "_crossref" do
104
+ it_behaves_like "a metadata accessor", :_crossref
105
+ end
106
+ describe "crossref" do
107
+ it_behaves_like "a metadata accessor", :crossref
108
+ end
109
+
110
+ describe "dc.creator" do
111
+ it_behaves_like "a metadata profile accessor with an alias", :dc, :creator
112
+ end
113
+ describe "dc.title" do
114
+ it_behaves_like "a metadata profile accessor with an alias", :dc, :title
115
+ end
116
+ describe "dc.publisher" do
117
+ it_behaves_like "a metadata profile accessor with an alias", :dc, :publisher
118
+ end
119
+ describe "dc.date" do
120
+ it_behaves_like "a metadata profile accessor with an alias", :dc, :date
121
+ end
122
+ describe "dc.type" do
123
+ it_behaves_like "a metadata profile accessor with an alias", :dc, :type
124
+ end
125
+
126
+ describe "datacite.creator" do
127
+ it_behaves_like "a metadata profile accessor with an alias", :datacite, :creator
128
+ end
129
+ describe "datacite.title" do
130
+ it_behaves_like "a metadata profile accessor with an alias", :datacite, :title
131
+ end
132
+ describe "datacite.publisher" do
133
+ it_behaves_like "a metadata profile accessor with an alias", :datacite, :publisher
134
+ end
135
+ describe "datacite.publicationyear" do
136
+ it_behaves_like "a metadata profile accessor with an alias", :datacite, :publicationyear
137
+ end
138
+ describe "datacite.resourcetype" do
139
+ it_behaves_like "a metadata profile accessor with an alias", :datacite, :resourcetype
140
+ end
141
+
142
+ describe "erc.who" do
143
+ it_behaves_like "a metadata profile accessor with an alias", :erc, :who
144
+ end
145
+ describe "erc.what" do
146
+ it_behaves_like "a metadata profile accessor with an alias", :erc, :what
147
+ end
148
+ describe "erc.when" do
149
+ it_behaves_like "a metadata profile accessor with an alias", :erc, :when
80
150
  end
81
151
  end
82
152
 
@@ -95,7 +165,7 @@ _status: public")
95
165
  end
96
166
  describe "encoding" do
97
167
  before do
98
- subject.each_key { |k| subject[k] = subject[k].force_encoding(Encoding::US_ASCII) }
168
+ subject.each { |k, v| subject[k] = v.force_encoding(Encoding::US_ASCII) }
99
169
  end
100
170
  it "should be encoded in UTF-8" do
101
171
  expect(subject.to_anvl.encoding).to eq(Encoding::UTF_8)
@@ -107,8 +177,8 @@ _status: public")
107
177
  subject { described_class.new(data) }
108
178
  context "of nil" do
109
179
  let(:data) { nil }
110
- it "should create an empty hash" do
111
- expect(subject).to eq({})
180
+ it "should create be empty" do
181
+ expect(subject).to be_empty
112
182
  end
113
183
  end
114
184
  context "of a string" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ezid-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chandek-Stark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-20 00:00:00.000000000 Z
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler