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.
@@ -1,3 +1,5 @@
1
+ require 'time'
2
+
1
3
  module Ezid
2
4
  RSpec.describe Metadata do
3
5
  describe "initializer" do
@@ -0,0 +1,169 @@
1
+ module Ezid
2
+ RSpec.describe MetadataTransformDatacite do
3
+ describe "#transform" do
4
+ before(:each) do
5
+ described_class.transform(test_hash)
6
+ end
7
+
8
+ context "when there are no datacite fields" do
9
+ let(:test_hash) { {} }
10
+ let(:expected_xml) { File.read("spec/fixtures/datacite_xml/empty.xml") }
11
+
12
+ it "populates a datacite xml field with all required fields as empty" do
13
+ expect(test_hash["datacite"]).to eq(expected_xml)
14
+ end
15
+ end
16
+
17
+ context "when there are datacite fields" do
18
+ let(:test_hash) { {
19
+ "datacite.identifier" => "TestIdentifier",
20
+ "datacite.identifiertype" => "TestIdentifierType",
21
+ "datacite.creator" => "TestCreatorName",
22
+ "datacite.title" => "TestTitle",
23
+ "datacite.publisher" => "TestPublisher",
24
+ "datacite.publicationyear" => "TestPublicationYear",
25
+ "datacite.resourcetype" => "TestResourceType",
26
+ "datacite.resourcetypegeneral" => "TestResourceTypeGeneral",
27
+ "datacite.description" => "TestDescription",
28
+ "some.other.field" => "SomeOtherValue",
29
+ } }
30
+ let(:expected_xml) { File.read("spec/fixtures/datacite_xml/populated.xml") }
31
+
32
+ it "populates a datacite xml field using values from the datacite.* fields" do
33
+ expect(test_hash["datacite"]).to eq(expected_xml)
34
+ end
35
+
36
+ it "removes the datacite.* fields from the hash" do
37
+ expect(test_hash.keys).not_to include(
38
+ "datacite.identifer",
39
+ "datacite.identifiertype",
40
+ "datacite.creator",
41
+ "datacite.title",
42
+ "datacite.publisher",
43
+ "datacite.publicationyear",
44
+ "datacite.resourcetype",
45
+ "datacite.resourcetypegeneral",
46
+ "datacite.description",
47
+ )
48
+ end
49
+
50
+ it "does not remove other fields" do
51
+ expect(test_hash).to include("some.other.field")
52
+ end
53
+ end
54
+ end
55
+
56
+ describe "#inverse" do
57
+ let(:test_hash) { {
58
+ "datacite" => test_xml,
59
+ "some.other.field" => "SomeOtherValue"
60
+ } }
61
+
62
+ before(:each) do
63
+ described_class.inverse(test_hash)
64
+ end
65
+
66
+
67
+ context "when there are no datacite fields" do
68
+ let(:expected_hash) { {
69
+ "datacite.identifier" => "",
70
+ "datacite.identifiertype" => "DOI",
71
+ "datacite.creator" => "",
72
+ "datacite.description" => "",
73
+ "datacite.publicationyear" => "",
74
+ "datacite.publisher" => "",
75
+ "datacite.resourcetype" => "",
76
+ "datacite.resourcetypegeneral" => "",
77
+ "datacite.title" => "",
78
+ } }
79
+ let(:test_xml) { File.read("spec/fixtures/datacite_xml/empty.xml") }
80
+
81
+ it "populates all required fields as empty" do
82
+ expect(test_hash).to include(expected_hash)
83
+ end
84
+ end
85
+
86
+ context "when there are datacite fields" do
87
+ let(:expected_hash) { {
88
+ "datacite.identifier" => "TestIdentifier",
89
+ "datacite.identifiertype" => "TestIdentifierType",
90
+ "datacite.creator" => "TestCreatorName",
91
+ "datacite.title" => "TestTitle",
92
+ "datacite.publisher" => "TestPublisher",
93
+ "datacite.publicationyear" => "TestPublicationYear",
94
+ "datacite.resourcetype" => "TestResourceType",
95
+ "datacite.resourcetypegeneral" => "TestResourceTypeGeneral",
96
+ "datacite.description" => "TestDescription",
97
+ } }
98
+ let(:test_xml) { File.read("spec/fixtures/datacite_xml/populated.xml") }
99
+
100
+ it "populates all fields from the datacite.* fields" do
101
+ expect(test_hash).to include(expected_hash)
102
+ end
103
+
104
+ it "removes the datacite field" do
105
+ expect(test_hash).not_to include("datacite")
106
+ end
107
+
108
+ it "does not remove other fields" do
109
+ expect(test_hash).to include("some.other.field")
110
+ end
111
+ end
112
+ end
113
+
114
+ describe "#transform then #inverse" do
115
+ let(:test_hash) { {
116
+ "datacite.identifier" => "TestIdentifier",
117
+ "datacite.identifiertype" => "TestIdentifierType",
118
+ "datacite.creator" => "TestCreatorName",
119
+ "datacite.title" => "TestTitle",
120
+ "datacite.publisher" => "TestPublisher",
121
+ "datacite.publicationyear" => "TestPublicationYear",
122
+ "datacite.resourcetype" => "TestResourceType",
123
+ "datacite.resourcetypegeneral" => "TestResourceTypeGeneral",
124
+ "datacite.description" => "TestDescription",
125
+ "some.other.field" => "SomeOtherValue",
126
+ } }
127
+
128
+ before(:each) do
129
+ described_class.transform(test_hash)
130
+ described_class.inverse(test_hash)
131
+ end
132
+
133
+ it "is a lossless transformation" do
134
+ expect(test_hash).to eq({
135
+ "datacite.identifier" => "TestIdentifier",
136
+ "datacite.identifiertype" => "TestIdentifierType",
137
+ "datacite.creator" => "TestCreatorName",
138
+ "datacite.title" => "TestTitle",
139
+ "datacite.publisher" => "TestPublisher",
140
+ "datacite.publicationyear" => "TestPublicationYear",
141
+ "datacite.resourcetype" => "TestResourceType",
142
+ "datacite.resourcetypegeneral" => "TestResourceTypeGeneral",
143
+ "datacite.description" => "TestDescription",
144
+ "some.other.field" => "SomeOtherValue",
145
+ })
146
+ end
147
+ end
148
+
149
+ describe "#inverse then #transform" do
150
+ let(:test_xml) { File.read("spec/fixtures/datacite_xml/empty.xml") }
151
+ let(:test_hash) { {
152
+ "datacite" => test_xml,
153
+ "some.other.field" => "SomeOtherValue"
154
+ } }
155
+
156
+ before(:each) do
157
+ described_class.inverse(test_hash)
158
+ described_class.transform(test_hash)
159
+ end
160
+
161
+ it "is a lossless transformation" do
162
+ expect(test_hash).to eq({
163
+ "datacite" => test_xml,
164
+ "some.other.field" => "SomeOtherValue"
165
+ })
166
+ end
167
+ end
168
+ end
169
+ end
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: 1.6.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chandek-Stark
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
11
+ date: 2021-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -30,34 +30,62 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.4.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: nokogiri
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: bundler
35
49
  requirement: !ruby/object:Gem::Requirement
36
50
  requirements:
37
- - - "~>"
51
+ - - ">="
38
52
  - !ruby/object:Gem::Version
39
- version: '1.7'
53
+ version: '0'
40
54
  type: :development
41
55
  prerelease: false
42
56
  version_requirements: !ruby/object:Gem::Requirement
43
57
  requirements:
44
- - - "~>"
58
+ - - ">="
45
59
  - !ruby/object:Gem::Version
46
- version: '1.7'
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: byebug
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
47
75
  - !ruby/object:Gem::Dependency
48
76
  name: rake
49
77
  requirement: !ruby/object:Gem::Requirement
50
78
  requirements:
51
- - - "~>"
79
+ - - ">="
52
80
  - !ruby/object:Gem::Version
53
- version: '10.5'
81
+ version: '0'
54
82
  type: :development
55
83
  prerelease: false
56
84
  version_requirements: !ruby/object:Gem::Requirement
57
85
  requirements:
58
- - - "~>"
86
+ - - ">="
59
87
  - !ruby/object:Gem::Version
60
- version: '10.5'
88
+ version: '0'
61
89
  - !ruby/object:Gem::Dependency
62
90
  name: rspec
63
91
  requirement: !ruby/object:Gem::Requirement
@@ -93,9 +121,9 @@ executables: []
93
121
  extensions: []
94
122
  extra_rdoc_files: []
95
123
  files:
124
+ - ".github/workflows/ruby.yml"
96
125
  - ".gitignore"
97
126
  - ".rspec"
98
- - ".travis.yml"
99
127
  - Gemfile
100
128
  - LICENSE.txt
101
129
  - README.md
@@ -103,13 +131,14 @@ files:
103
131
  - VERSION
104
132
  - ezid-client.gemspec
105
133
  - lib/ezid-client.rb
134
+ - lib/ezid/batch.rb
106
135
  - lib/ezid/batch_download.rb
107
- - lib/ezid/batch_enumerator.rb
108
136
  - lib/ezid/client.rb
109
137
  - lib/ezid/configuration.rb
110
138
  - lib/ezid/error.rb
111
139
  - lib/ezid/identifier.rb
112
140
  - lib/ezid/metadata.rb
141
+ - lib/ezid/metadata_transforms/datacite.rb
113
142
  - lib/ezid/proxy_identifier.rb
114
143
  - lib/ezid/requests/batch_download_request.rb
115
144
  - lib/ezid/requests/create_identifier_request.rb
@@ -139,21 +168,24 @@ files:
139
168
  - lib/ezid/status.rb
140
169
  - lib/ezid/test_helper.rb
141
170
  - spec/fixtures/anvl_batch.txt
171
+ - spec/fixtures/datacite_xml/empty.xml
172
+ - spec/fixtures/datacite_xml/populated.xml
142
173
  - spec/integration/batch_download_spec.rb
143
174
  - spec/integration/client_spec.rb
144
175
  - spec/integration/identifier_spec.rb
145
176
  - spec/spec_helper.rb
146
177
  - spec/unit/batch_download_request_spec.rb
147
- - spec/unit/batch_enumerator_spec.rb
178
+ - spec/unit/batch_spec.rb
148
179
  - spec/unit/client_spec.rb
149
180
  - spec/unit/identifier_spec.rb
150
181
  - spec/unit/metadata_spec.rb
182
+ - spec/unit/metadata_transform_datacite_spec.rb
151
183
  - spec/unit/proxy_identifier_spec.rb
152
184
  homepage: https://github.com/duke-libraries/ezid-client
153
185
  licenses:
154
186
  - BSD-3-Clause
155
187
  metadata: {}
156
- post_install_message:
188
+ post_install_message:
157
189
  rdoc_options: []
158
190
  require_paths:
159
191
  - lib
@@ -161,27 +193,29 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
193
  requirements:
162
194
  - - "~>"
163
195
  - !ruby/object:Gem::Version
164
- version: '2.0'
196
+ version: '2.1'
165
197
  required_rubygems_version: !ruby/object:Gem::Requirement
166
198
  requirements:
167
199
  - - ">="
168
200
  - !ruby/object:Gem::Version
169
201
  version: '0'
170
202
  requirements: []
171
- rubyforge_project:
172
- rubygems_version: 2.6.8
173
- signing_key:
203
+ rubygems_version: 3.0.8
204
+ signing_key:
174
205
  specification_version: 4
175
206
  summary: Ruby client for EZID API Version 2
176
207
  test_files:
177
208
  - spec/fixtures/anvl_batch.txt
209
+ - spec/fixtures/datacite_xml/empty.xml
210
+ - spec/fixtures/datacite_xml/populated.xml
178
211
  - spec/integration/batch_download_spec.rb
179
212
  - spec/integration/client_spec.rb
180
213
  - spec/integration/identifier_spec.rb
181
214
  - spec/spec_helper.rb
182
215
  - spec/unit/batch_download_request_spec.rb
183
- - spec/unit/batch_enumerator_spec.rb
216
+ - spec/unit/batch_spec.rb
184
217
  - spec/unit/client_spec.rb
185
218
  - spec/unit/identifier_spec.rb
186
219
  - spec/unit/metadata_spec.rb
220
+ - spec/unit/metadata_transform_datacite_spec.rb
187
221
  - spec/unit/proxy_identifier_spec.rb
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.1
5
- - 2.2
6
- - 2.1
7
- - 2.0.0
8
- cache:
9
- - bundler
10
- script: "bundle exec rake ci"