stanford-mods 3.0.0.alpha1 → 3.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
  SHA256:
3
- metadata.gz: bccde0bc740f4135ee9de0b7255f3ac347a16c858ca463801111f37f8ad84ecc
4
- data.tar.gz: a6e3fc9534efe4e37b05bf047007a5b9e3cd41f662e568b1b2333a1cc1213dce
3
+ metadata.gz: 70d3b7093c830baa3c12f4c2c438549eb451fa4b6bb6c57f458382f0e8e53dc2
4
+ data.tar.gz: 044edaeef524c4a701ebbc0e25f08d0c3fb5068b04cc36ab8769772004a73a85
5
5
  SHA512:
6
- metadata.gz: 7ab80915b8f299e35822e9f2b6e0047cf1b32c62bec9ac0218daeb0d7bd3fb4753d1668075b754e5a9a955098fb785c94a9c188654295894c2867fc7d04f7574
7
- data.tar.gz: fb1e1835b67fb30c7d19c2046c08a9a60bddda35b6b4067bb3518c8d8d9385a09d80846fc46e958f67d9a0eb89dcb2aef36ede3da03fc723f0158d1db3b81ee9
6
+ metadata.gz: '097830e7c3b1136a279dfce41ac426ae860ab020f27bb1550a3f2a5f23b7fcbc1c7f7952f35f06a44aed7100d0d410c39adcbb17a70b270174c85b757d1aca4b'
7
+ data.tar.gz: 7aa1c33f53fdbd4160d99a14739b4dcbd37950f4d8ab8238ee1886d4b6db4aaa9b5dec4c92f74842db80aa9839ec2d7e27a570a4fb7cde4862afc54b79c9e6a4
@@ -25,7 +25,7 @@ module Stanford
25
25
 
26
26
  # @return [Array<String>] values for author_person_facet, author_person_display
27
27
  def sw_person_authors
28
- mods_ng_xml.personal_names.map(&:display_value_w_date)
28
+ mods_ng_xml.personal_name.map(&:display_value_w_date)
29
29
  end
30
30
 
31
31
  # return the display_value_w_date for all <mods><name> elements that do not have type='personal'
@@ -72,6 +72,10 @@ module Stanford
72
72
  origin_info.map { |el| Stanford::Mods::Imprint.new(el) }
73
73
  end
74
74
 
75
+ def place
76
+ term_values([:origin_info, :place, :placeTerm])
77
+ end
78
+
75
79
  # @return [String] single String containing imprint information for display
76
80
  def imprint_display_str
77
81
  imprints.map(&:display_str).reject(&:empty?).join('; ')
@@ -9,41 +9,49 @@ module Stanford
9
9
  # Searchworks requires that the MODS has a '//titleInfo/title'
10
10
  # @return [String] value for title_245_search, title_full_display
11
11
  def sw_full_title(title_info = first_title_info_node, sortable: false)
12
- return unless title_info
12
+ return unless title_info&.children&.any?
13
13
 
14
14
  title = title_info.title&.text&.strip
15
-
16
15
  return if title.nil? || title.empty?
17
16
 
18
- nonSort_title = title_info.nonSort&.text&.strip
17
+ title = ''
18
+ previous_element = nil
19
+
20
+ title_info.children.select { |value| title_parts.include? value.name }.each do |value|
21
+ next if value.name == 'nonSort' && sortable
19
22
 
20
- preSubTitle = [(nonSort_title unless sortable), title].compact.join(' ')
23
+ str = value.text.strip
24
+ next if str.empty?
21
25
 
22
- preSubTitle.sub!(/:$/, '')
26
+ delimiter = if title.empty? || title.end_with?(' ')
27
+ nil
28
+ elsif previous_element&.name == 'nonSort' && title.end_with?('-', '\'')
29
+ nil
30
+ elsif title.end_with?('.', ',', ':', ';')
31
+ ' '
32
+ elsif value.name == 'subTitle'
33
+ ' : '
34
+ elsif value.name == 'partName' && previous_element.name == 'partNumber'
35
+ ', '
36
+ elsif value.name == 'partNumber' || value.name == 'partName'
37
+ '. '
38
+ else
39
+ ' '
40
+ end
23
41
 
24
- subTitle = title_info.subTitle.text.strip
25
- preParts = subTitle.empty? ? preSubTitle : preSubTitle + " : " + subTitle
26
- preParts.sub!(/\.$/, '') if preParts # remove trailing period
42
+ title += delimiter if delimiter
43
+ title += str
27
44
 
28
- partName = title_info.partName.text.strip unless title_info.partName.text.strip.empty?
29
- partNumber = title_info.partNumber.text.strip unless title_info.partNumber.text.strip.empty?
30
- partNumber.sub!(/,$/, '') if partNumber # remove trailing comma
31
- if partNumber && partName
32
- parts = partNumber + ", " + partName
33
- elsif partNumber
34
- parts = partNumber
35
- elsif partName
36
- parts = partName
45
+ previous_element = value
37
46
  end
38
- parts.sub!(/\.$/, '') if parts
39
47
 
40
- result = parts ? preParts + ". " + parts : preParts
41
- return nil unless result
48
+ title += "." unless title =~ /\s*[[:punct:]]$/
49
+
50
+ title.strip
51
+ end
42
52
 
43
- result += "." unless result =~ /[[:punct:]]$/
44
- result.strip!
45
- result = nil if result.empty?
46
- result
53
+ def title_parts
54
+ %w[nonSort title subTitle partName partNumber]
47
55
  end
48
56
 
49
57
  # like sw_full_title without trailing \,/;:.
@@ -57,7 +65,7 @@ module Stanford
57
65
  # this includes all titles except
58
66
  # @return [Array<String>] values for title_variant_search
59
67
  def sw_addl_titles
60
- (full_titles - first_title_info_node.full_title).reject(&:blank?)
68
+ (full_titles - Array(first_title_info_node&.full_title)).reject(&:blank?)
61
69
  end
62
70
 
63
71
  # Returns a sortable version of the main title
@@ -76,4 +84,4 @@ module Stanford
76
84
  end
77
85
  end
78
86
  end
79
- end
87
+ end
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = '3.0.0.alpha1'.freeze
4
+ VERSION = '3.0.0'.freeze
5
5
  end
6
6
  end
@@ -3,7 +3,7 @@ describe 'title fields (searchworks.rb)' do
3
3
  before(:all) do
4
4
  @smods_rec = Stanford::Mods::Record.new
5
5
  @ns_decl = "xmlns='#{Mods::MODS_NS}'"
6
- m = "<mods #{@ns_decl}><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>"
6
+ m = "<mods #{@ns_decl}><titleInfo><nonSort>The</nonSort><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle></titleInfo></mods>"
7
7
  @smods_rec.from_str m
8
8
  end
9
9
 
@@ -19,7 +19,7 @@ describe 'title fields (searchworks.rb)' do
19
19
 
20
20
  context 'blank title node' do
21
21
  it 'should deal with a second blank titleInfo node' do
22
- m = "<mods #{@ns_decl}><titleInfo> </titleInfo><otherStuff>goes here</otherStuff><titleInfo><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle><nonSort>The</nonSort></titleInfo></mods>"
22
+ m = "<mods #{@ns_decl}><titleInfo> </titleInfo><otherStuff>goes here</otherStuff><titleInfo><nonSort>The</nonSort><title>Jerk</title><subTitle>A Tale of Tourettes</subTitle>></titleInfo></mods>"
23
23
  smods_rec_blank_node = Stanford::Mods::Record.new
24
24
  smods_rec_blank_node.from_str m
25
25
  expect(smods_rec_blank_node.sw_short_title).to eq 'The Jerk'
@@ -113,7 +113,7 @@ describe 'title fields (searchworks.rb)' do
113
113
  <subTitle>a history</subTitle>
114
114
  </titleInfo></mods>"
115
115
  @smods_rec.from_str(m)
116
- expect(@smods_rec.sw_full_title).to eq 'The Olympics : a history.'
116
+ expect(@smods_rec.sw_full_title).to eq 'The Olympics: a history.'
117
117
  end #
118
118
  # "end subtitle with period" - see above
119
119
  it 'subtitle already ends with period' do
@@ -389,7 +389,7 @@ describe 'title fields (searchworks.rb)' do
389
389
  <subTitle>a history</subTitle>
390
390
  </titleInfo></mods>"
391
391
  @smods_rec.from_str(m)
392
- expect(@smods_rec.sw_title_display).to eq 'The Olympics : a history'
392
+ expect(@smods_rec.sw_title_display).to eq 'The Olympics: a history'
393
393
  end #
394
394
  # "end subtitle with period" - see above
395
395
  it 'subtitle already ends with period' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stanford-mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.alpha1
4
+ version: 3.0.0
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-02-01 00:00:00.000000000 Z
12
+ date: 2022-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods
@@ -213,9 +213,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  requirements:
216
- - - ">"
216
+ - - ">="
217
217
  - !ruby/object:Gem::Version
218
- version: 1.3.1
218
+ version: '0'
219
219
  requirements: []
220
220
  rubygems_version: 3.2.32
221
221
  signing_key: