mods 3.0.2 → 3.0.4

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
  SHA256:
3
- metadata.gz: cea16c53599001b8cede7fb85bffef53aa28de61718785af76fd5445915fc80c
4
- data.tar.gz: fba29c21dd8bc15483de289aafb690616b6bd6af817d6252915e41238bf1ed70
3
+ metadata.gz: ba231dc5a8e9d54605e9b7a066419c6d0bb63430bf0a245b7c143b206360daf6
4
+ data.tar.gz: 9ae4a4448f22fb661ff683dc1f4612be5a0531a7f41a1f8d0f2b59ef2232d180
5
5
  SHA512:
6
- metadata.gz: e6ec16f53b9355f57315248e6eabd57d3db32743e4235365f119a519c36abc0d47e75af9c600ac2666bc5db9b2c77a6629e1ace33b847077606ef3bd32d65f78
7
- data.tar.gz: 2028457eec91d93b8a44d48d2da3152d6808e850dbc201a199deb43465464497d18611049b888b5a0f2029db5166e7c99e34206f9bde2480e04e4bcf3d6eb7b2
6
+ metadata.gz: 7d8680c108fb0b5f915474530a73d097b52efd5ecb940b701a02d08228f56bf63be8194e034713949dfed6548a38236fe736089e0a792e453a50b00e627442ef
7
+ data.tar.gz: 3ddc2d8b385002a230a5a913f9f393ae8aabe4919569a19cd1c847404fe51e9ecc2e8e0951c87e07a312971eb5095619672487ffa9d0963cb7dfebbca11c8437
data/lib/mods/date.rb CHANGED
@@ -183,7 +183,7 @@ module Mods
183
183
 
184
184
  def self.munge_to_yyyy(text)
185
185
  value = roman_to_int(text.upcase)
186
- (value - 1).to_s.rjust(2, "0") + 'XX'
186
+ (value - 1).to_s.rjust(2, "0") + 'xx'
187
187
  end
188
188
  end
189
189
 
@@ -194,7 +194,7 @@ module Mods
194
194
  REGEX = /(?<century>\d{2})--/
195
195
  def self.normalize_to_edtf(text)
196
196
  matches = text.match(REGEX)
197
- "#{matches[:century]}XX"
197
+ "#{matches[:century]}xx"
198
198
  end
199
199
  end
200
200
 
@@ -204,7 +204,7 @@ module Mods
204
204
 
205
205
  def self.normalize_to_edtf(text)
206
206
  matches = text.match(REGEX)
207
- "#{matches[:century].to_i - 1}XX"
207
+ "#{matches[:century].to_i - 1}xx"
208
208
  end
209
209
  end
210
210
 
@@ -224,7 +224,7 @@ module Mods
224
224
 
225
225
  def self.normalize_to_edtf(text)
226
226
  matches = text.match(REGEX)
227
- "#{matches[:year]}X"
227
+ "#{matches[:year]}x"
228
228
  end
229
229
  end
230
230
 
@@ -234,7 +234,7 @@ module Mods
234
234
 
235
235
  def self.normalize_to_edtf(text)
236
236
  matches = text.match(REGEX)
237
- "#{matches[:year]}X"
237
+ "#{matches[:year]}x"
238
238
  end
239
239
  end
240
240
 
@@ -460,6 +460,8 @@ module Mods
460
460
  :century
461
461
  elsif date_range.is_a? EDTF::Decade
462
462
  :decade
463
+ elsif date.is_a? EDTF::Season
464
+ :month
463
465
  elsif date.is_a? EDTF::Interval
464
466
  date_range.precision
465
467
  else
@@ -497,7 +499,7 @@ module Mods
497
499
  case date_range
498
500
  when EDTF::Unknown
499
501
  nil
500
- when EDTF::Epoch, EDTF::Interval
502
+ when EDTF::Epoch, EDTF::Interval, EDTF::Season
501
503
  date_range.min
502
504
  when EDTF::Set
503
505
  date_range.to_a.first
@@ -522,7 +524,7 @@ module Mods
522
524
  case date_range
523
525
  when EDTF::Unknown
524
526
  nil
525
- when EDTF::Epoch, EDTF::Interval
527
+ when EDTF::Epoch, EDTF::Interval, EDTF::Season
526
528
  date_range.max
527
529
  when EDTF::Set
528
530
  date_range.to_a.last.change(month: 12, day: 31)
@@ -538,7 +540,7 @@ module Mods
538
540
 
539
541
  def date_range
540
542
  @date_range ||= if text =~ /u/
541
- ::Date.edtf(text.gsub('u', 'X')) || date
543
+ ::Date.edtf(text.gsub('u', 'x').gsub('X', 'x')) || date
542
544
  else
543
545
  date
544
546
  end
data/lib/mods/name.rb CHANGED
@@ -2,8 +2,8 @@ module Mods
2
2
 
3
3
  class Name
4
4
 
5
- CHILD_ELEMENTS = ['namePart', 'displayForm', 'affiliation', 'role', 'description']
6
-
5
+ CHILD_ELEMENTS = ['namePart', 'displayForm', 'affiliation', 'role', 'nameIdentifier', 'description']
6
+
7
7
  # attributes on name node
8
8
  ATTRIBUTES = Mods::AUTHORITY_ATTRIBS + Mods::LANG_ATTRIBS + ['type', 'displayLabel', 'usage', 'altRepGroup', 'nameTitleGroup']
9
9
 
@@ -11,7 +11,7 @@ module Mods
11
11
  TYPES = ['personal', 'corporate', 'conference', 'family']
12
12
  # valid values for type attribute on namePart node <name><namePart type="val"/></name>
13
13
  NAME_PART_TYPES = ['date', 'family', 'given', 'termsOfAddress']
14
-
14
+
15
15
  end
16
-
16
+
17
17
  end
@@ -143,6 +143,9 @@ module Mods
143
143
  end
144
144
  n.displayForm :path => 'm:displayForm'
145
145
  n.affiliation :path => 'm:affiliation'
146
+ n.nameIdentifier :path => 'm:nameIdentifier' do |ni|
147
+ with_attributes(ni, Mods::LANG_ATTRIBS | %w[displayLabel type typeURI invalid])
148
+ end
146
149
  n.description_el :path => 'm:description' # description is used by Nokogiri
147
150
  n.role :path => 'm:role' do |r|
148
151
  r.roleTerm :path => 'm:roleTerm' do |rt|
data/lib/mods/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Mods
2
2
  # this is the Ruby Gem version
3
- VERSION = '3.0.2'.freeze
3
+ VERSION = '3.0.4'.freeze
4
4
  end
@@ -101,7 +101,8 @@ RSpec.describe Mods::Date do
101
101
  '1900-06' => :month,
102
102
  '1900-06-uu' => :month,
103
103
  '1900-06-15' => :day,
104
- '2014-01-01/2020-12-31' => :day
104
+ '2014-01-01/2020-12-31' => :day,
105
+ '1986-22' => :month
105
106
  }.each do |data, expected|
106
107
  describe "with #{data}" do
107
108
  let(:date_element) { "<dateCreated encoding=\"edtf\">#{data}</dateCreated>" }
@@ -201,9 +202,9 @@ RSpec.describe Mods::Date do
201
202
  {
202
203
  '1905' => Date.parse('1905-01-01')..Date.parse('1905-12-31'),
203
204
  '190u' => Date.parse('1900-01-01')..Date.parse('1909-12-31'),
204
- '190X' => Date.parse('1900-01-01')..Date.parse('1909-12-31'),
205
+ '190x' => Date.parse('1900-01-01')..Date.parse('1909-12-31'),
205
206
  '19uu' => Date.parse('1900-01-01')..Date.parse('1999-12-31'),
206
- '19XX' => Date.parse('1900-01-01')..Date.parse('1999-12-31'),
207
+ '19xx' => Date.parse('1900-01-01')..Date.parse('1999-12-31'),
207
208
  '1856/1876' => Date.parse('1856-01-01')..Date.parse('1876-12-31'),
208
209
  '[1667,1668,1670..1672]' => Date.parse('1667-01-01')..Date.parse('1672-12-31'),
209
210
  '1900-uu' => Date.parse('1900-01-01')..Date.parse('1900-12-31'),
@@ -197,6 +197,7 @@ RSpec.describe "Mods <name> Element" do
197
197
  <name>
198
198
  <namePart>Exciting Prints</namePart>
199
199
  <affiliation>whatever</affiliation>
200
+ <nameIdentifier typeURI="https://orcid.org" type="orcid">0000-0002-0666-0666</nameIdentifier>
200
201
  <description>anything</description>
201
202
  <role><roleTerm type='text'>some role</roleTerm></role>
202
203
  </name>
@@ -280,6 +281,26 @@ RSpec.describe "Mods <name> Element" do
280
281
  end
281
282
  end
282
283
 
284
+ context 'with a nameIdentifier' do
285
+ subject(:record) do
286
+ mods_record(<<-XML)
287
+ <name>
288
+ <name type="personal">Whoopie Goldberg</name>
289
+ <nameIdentifier typeURI="https://orcid.org" type="orcid">0000-0002-0666-0666</nameIdentifier>
290
+ <role><roleTerm type='text'>some role</roleTerm></role>
291
+ </name>
292
+ XML
293
+ end
294
+
295
+ it 'has the expected attributes for nameIdentifier' do
296
+ expect(record.plain_name.nameIdentifier.first).to have_attributes(
297
+ text: '0000-0002-0666-0666',
298
+ typeURI: 'https://orcid.org',
299
+ type_at: 'orcid'
300
+ )
301
+ end
302
+ end
303
+
283
304
  context 'without a family name and given name' do
284
305
  subject(:record) do
285
306
  mods_record("<name type='personal'>
@@ -349,6 +370,7 @@ RSpec.describe "Mods <name> Element" do
349
370
  </name>
350
371
  <name>
351
372
  <namePart>Daniel Craig</namePart>
373
+ <nameIdentifier typeURI="https://orcid.org" type="orcid">0000-0002-0666-0666</nameIdentifier>
352
374
  <role>
353
375
  <roleTerm type='text' authority='marcrelator'>Actor</roleTerm>
354
376
  <roleTerm type='code' authority='marcrelator'>cre</roleTerm>
@@ -363,6 +385,12 @@ RSpec.describe "Mods <name> Element" do
363
385
  have_attributes(role: have_attributes(value: ['CreatorFake', 'Actor'], code: ['cre'], authority: ['marcrelator', 'marcrelator'], size: 2)),
364
386
  have_attributes(role: have_attributes(value: ['Actor'], code: ['cre'], authority: ['marcrelator'], size: 1)),
365
387
  ])
388
+ expect(record.plain_name.last.nameIdentifier.first).to have_attributes(
389
+ text: '0000-0002-0666-0666',
390
+ typeURI: 'https://orcid.org',
391
+ type_at: 'orcid'
392
+ )
393
+ expect(record.plain_name.first.nameIdentifier).to be_empty
366
394
  end
367
395
  end
368
396
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-11 00:00:00.000000000 Z
12
+ date: 2023-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  - !ruby/object:Gem::Version
223
223
  version: '0'
224
224
  requirements: []
225
- rubygems_version: 3.2.32
225
+ rubygems_version: 3.4.13
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: Parse MODS (Metadata Object Description Schema) records.