mods_display 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mods_display/fields/location.rb +1 -1
- data/lib/mods_display/fields/title.rb +39 -32
- data/lib/mods_display/version.rb +1 -1
- data/spec/fields/location_spec.rb +1 -1
- data/spec/fields/title_spec.rb +8 -0
- data/spec/fixtures/title_fixtures.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 586a8299be19e795bc90b434d9902084ca8fa10bb8cbe9690fc108471e1f5495
|
4
|
+
data.tar.gz: 00574a48dc3c3ba050529bf2d3fcd5e38df5de4c0e5ed4023ad07904dea29c99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9430fa89a1efb94a17ec8c83f5fc96e55f96221f962480ff6a71a9283548d385e1afabe1c8653215155a8d7804648075aae93d217ff2d25ec29357c5b2e64544
|
7
|
+
data.tar.gz: 0d7b2e673cae7f336e65824c528b78abd59e8b730430570faa98910cf715e875a707dde7787a48cbf158f15bc596b057181c443d253387136604b307036812ea
|
@@ -4,31 +4,10 @@ module ModsDisplay
|
|
4
4
|
return_values = []
|
5
5
|
if @values
|
6
6
|
@values.each do |value|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
)
|
12
|
-
else
|
13
|
-
nonSort = nil
|
14
|
-
title = nil
|
15
|
-
subTitle = nil
|
16
|
-
nonSort = value.nonSort.text.strip unless value.nonSort.text.strip.empty?
|
17
|
-
title = value.title.text.strip unless value.title.text.strip.empty?
|
18
|
-
subTitle = value.subTitle.text unless value.subTitle.text.strip.empty?
|
19
|
-
preSubTitle = [nonSort, title].compact.join(' ')
|
20
|
-
preSubTitle = nil if preSubTitle.strip.empty?
|
21
|
-
preParts = compact_and_join_with_delimiter([preSubTitle, subTitle], ' : ')
|
22
|
-
preParts = nil if preParts.strip.empty?
|
23
|
-
parts = value.children.select do |child|
|
24
|
-
%w(partName partNumber).include?(child.name)
|
25
|
-
end.map(&:text).compact.join(parts_delimiter(value))
|
26
|
-
parts = nil if parts.strip.empty?
|
27
|
-
return_values << ModsDisplay::Values.new(
|
28
|
-
label: displayLabel(value) || title_label(value),
|
29
|
-
values: [compact_and_join_with_delimiter([preParts, parts], '. ')]
|
30
|
-
)
|
31
|
-
end
|
7
|
+
return_values << ModsDisplay::Values.new(
|
8
|
+
label: displayLabel(value) || title_label(value),
|
9
|
+
values: [assemble_title(value)]
|
10
|
+
)
|
32
11
|
end
|
33
12
|
end
|
34
13
|
collapse_fields(return_values)
|
@@ -36,14 +15,42 @@ module ModsDisplay
|
|
36
15
|
|
37
16
|
private
|
38
17
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
18
|
+
def assemble_title(element)
|
19
|
+
return displayForm(element) if displayForm(element)
|
20
|
+
|
21
|
+
title = ''
|
22
|
+
previous_element = nil
|
23
|
+
|
24
|
+
element.children.select { |value| title_parts.include? value.name }.each do |value|
|
25
|
+
str = value.text.strip
|
26
|
+
next if str.empty?
|
27
|
+
|
28
|
+
delimiter = case
|
29
|
+
when title.empty?, title.end_with?(' ')
|
30
|
+
nil
|
31
|
+
when title.end_with?('.', ',', ':', ';')
|
32
|
+
' '
|
33
|
+
when value.name == 'subTitle'
|
34
|
+
' : '
|
35
|
+
when value.name == 'partName' && previous_element.name == 'partNumber'
|
36
|
+
', '
|
37
|
+
when value.name == 'partNumber', value.name == 'partName'
|
38
|
+
'. '
|
39
|
+
else
|
40
|
+
' '
|
41
|
+
end
|
42
|
+
|
43
|
+
title += delimiter if delimiter
|
44
|
+
title += str
|
45
|
+
|
46
|
+
previous_element = value
|
45
47
|
end
|
46
|
-
|
48
|
+
|
49
|
+
title
|
50
|
+
end
|
51
|
+
|
52
|
+
def title_parts
|
53
|
+
%w[nonSort title subTitle partName partNumber]
|
47
54
|
end
|
48
55
|
|
49
56
|
def title_label(element)
|
data/lib/mods_display/version.rb
CHANGED
data/spec/fields/title_spec.rb
CHANGED
@@ -15,6 +15,7 @@ describe ModsDisplay::Title do
|
|
15
15
|
@multi_label = Stanford::Mods::Record.new.from_str(multi_label_fixture, false).title_info
|
16
16
|
@alt_title = Stanford::Mods::Record.new.from_str(alt_title_fixture, false).title_info
|
17
17
|
@title_punctuation = Stanford::Mods::Record.new.from_str(title_puncutation_fixture, false).title_info
|
18
|
+
@ordered_title_fixture = Stanford::Mods::Record.new.from_str(ordered_title_fixture, false).title_info
|
18
19
|
end
|
19
20
|
describe 'labels' do
|
20
21
|
it 'should return a default label of Title if nothing else is available' do
|
@@ -70,5 +71,12 @@ describe ModsDisplay::Title do
|
|
70
71
|
expect(values.first).not_to include '..'
|
71
72
|
expect(values.first).to eq 'A title that ends in punctuation. 2015'
|
72
73
|
end
|
74
|
+
|
75
|
+
it 'combines the title parts in the order from the record' do
|
76
|
+
values = mods_display_title(@ordered_title_fixture).fields.first.values
|
77
|
+
expect(values.length).to eq 1
|
78
|
+
|
79
|
+
expect(values.first).to eq 'The medium term expenditure framework (MTEF) for ... and the annual estimates for ... 016, Ministry of Tourism : expenditure to be met out of moneys granted and drawn from the consolidated fund, central government budget'
|
80
|
+
end
|
73
81
|
end
|
74
82
|
end
|
@@ -98,4 +98,18 @@ module TitleFixtures
|
|
98
98
|
</mods>
|
99
99
|
XML
|
100
100
|
end
|
101
|
+
|
102
|
+
def ordered_title_fixture
|
103
|
+
<<-XML
|
104
|
+
<mods>
|
105
|
+
<titleInfo>
|
106
|
+
<nonSort>The</nonSort>
|
107
|
+
<title>medium term expenditure framework (MTEF) for ... and the annual estimates for ...</title>
|
108
|
+
<partNumber>016</partNumber>
|
109
|
+
<partName>Ministry of Tourism</partName>
|
110
|
+
<subTitle>expenditure to be met out of moneys granted and drawn from the consolidated fund, central government budget</subTitle>
|
111
|
+
</titleInfo>
|
112
|
+
</mods>
|
113
|
+
XML
|
114
|
+
end
|
101
115
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mods_display
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jessie Keck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stanford-mods
|