mods_display 0.4.1 → 0.5.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 +4 -4
- data/.travis.yml +3 -2
- data/Gemfile +3 -0
- data/README.md +18 -9
- data/config/locales/en.yml +3 -1
- data/lib/mods_display.rb +2 -0
- data/lib/mods_display/configuration.rb +4 -0
- data/lib/mods_display/fields/contents.rb +18 -0
- data/lib/mods_display/fields/name.rb +63 -45
- data/lib/mods_display/fields/nested_related_item.rb +60 -0
- data/lib/mods_display/fields/related_item.rb +3 -8
- data/lib/mods_display/fields/subject.rb +2 -6
- data/lib/mods_display/html.rb +4 -1
- data/lib/mods_display/related_item_concerns.rb +27 -0
- data/lib/mods_display/version.rb +1 -1
- data/mods_display.gemspec +2 -0
- data/spec/fields/contents_spec.rb +15 -0
- data/spec/fields/name_spec.rb +52 -35
- data/spec/fields/nested_related_item_spec.rb +72 -0
- data/spec/fields/related_item_spec.rb +7 -0
- data/spec/fields/subject_spec.rb +2 -3
- data/spec/fixtures/name_fixtures.rb +202 -0
- data/spec/fixtures/nested_realted_items_fixtures.rb +64 -0
- data/spec/spec_helper.rb +2 -0
- metadata +37 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d059d0bb717d798e323ae91d62ac65420e0b7e34
|
4
|
+
data.tar.gz: bea28312f2984465139f312e585a315ec8de992f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7f53d54b8fbbd9dee47ccbee7120e63725e63057602da3a3cd50f569fc1d3335ed38a326d0ae072a25457f207d4ccc7722aa79a28dab3f442b2bf78f81ea35a
|
7
|
+
data.tar.gz: 306dee0b66098f941dcfbb8c8f8138b001cf4f34b06b398b73a118c9f785b73c9ebab33f9e7b0233aa7cb6d8122034a0bc77f87ba355d5bc29fa45046ba6dca6
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ And then execute:
|
|
21
21
|
Or install it yourself as:
|
22
22
|
|
23
23
|
$ gem install mods_display
|
24
|
-
|
24
|
+
|
25
25
|
Include the `ModelExtension` into your model.
|
26
26
|
|
27
27
|
class MyClass
|
@@ -32,11 +32,11 @@ Configure the source of the MODS XML in your model. You can pass a string of XM
|
|
32
32
|
|
33
33
|
class MyClass
|
34
34
|
....
|
35
|
-
|
35
|
+
|
36
36
|
mods_xml_source do |model|
|
37
37
|
model.mods
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
end
|
41
41
|
|
42
42
|
Include the `ControllerExtension` into your rails controller (or another class if not using rails).
|
@@ -44,7 +44,7 @@ Include the `ControllerExtension` into your rails controller (or another class i
|
|
44
44
|
class MyController
|
45
45
|
include ModsDisplay::ControllerExtension
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
Optionally configure the mods display gem (more on configuration later).
|
49
49
|
|
50
50
|
class MyController
|
@@ -70,7 +70,7 @@ Both label_ and value_class accept strings to put in as a class.
|
|
70
70
|
|
71
71
|
class MyController
|
72
72
|
include ModsDisplay::ControllerExtension
|
73
|
-
|
73
|
+
|
74
74
|
configure_mods_display do
|
75
75
|
title do
|
76
76
|
label_class "title-label"
|
@@ -85,7 +85,7 @@ In certain cases an application may need to explicitly remove a portion of the M
|
|
85
85
|
|
86
86
|
class MyController
|
87
87
|
include ModsDisplay::ControllerExtension
|
88
|
-
|
88
|
+
|
89
89
|
configure_mods_display do
|
90
90
|
contact do
|
91
91
|
ignore!
|
@@ -111,13 +111,13 @@ The link configuration option takes 2 parameters. The first is a key that is a m
|
|
111
111
|
|
112
112
|
class MyController
|
113
113
|
include ModsDisplay::ControllerExtension
|
114
|
-
|
114
|
+
|
115
115
|
configure_mods_display do
|
116
116
|
format do
|
117
117
|
link :format_path, '"%value%"'
|
118
118
|
end
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
def format_path(format)
|
122
122
|
"http://example.com/?f[format_field][]=#{format}"
|
123
123
|
end
|
@@ -128,7 +128,7 @@ The link configuration option takes 2 parameters. The first is a key that is a m
|
|
128
128
|
Depending on the implementation of subjects there may be different ways you would want to link them. The standard way of linking will just create a link passing the value to the href and the link text. However; in certain cases the subjects should be linked so that each subject to the right of a delimiter should have the values of all its preceding values in the href.
|
129
129
|
|
130
130
|
[Country](http://example.com/?"Country") > [State](http://example.com/?"Country State") > [City](http://example.com/?"Country State City")
|
131
|
-
|
131
|
+
|
132
132
|
This can be accomplished by setting the hierarchical_link configuration option to true for subjects
|
133
133
|
|
134
134
|
configure_mods_display do
|
@@ -182,6 +182,15 @@ Given that this semantics that we're concerned with here are more about titles a
|
|
182
182
|
|
183
183
|
## Release/Upgrade Notes
|
184
184
|
|
185
|
+
#### v0.5.0
|
186
|
+
There are three major changes in this version.
|
187
|
+
|
188
|
+
1. RelatedItem nodes with a type of `constituent` or `host` are now treated separately and will render the full MODS display of any nested metadata. If accessing the `ModsDisplay::Values` directly through their accessors (e.g. custom grouping), this new metadata is available under `.nested_related_items`.
|
189
|
+
* _**Note:** You may want to style and add some javascript toggling behavior (see exhibits for an example)._
|
190
|
+
2. Name nodes are now grouped/labeled by their role. If you were iterating over the names and splitting them out by their labels, that will need to change.
|
191
|
+
3. Table of contents/Summaries are now split on `--` and rendered as an unordered list.
|
192
|
+
* _**Note:** You may want to style this list._
|
193
|
+
|
185
194
|
#### v0.3.0
|
186
195
|
|
187
196
|
Labels now have internationalization support. We have added colons to the english labels due to certain languages' punctuation rules requiring different spacing between the label and colon.
|
data/config/locales/en.yml
CHANGED
@@ -4,12 +4,13 @@ en:
|
|
4
4
|
abstract: "Abstract:"
|
5
5
|
access_condition: "Access condition:"
|
6
6
|
alternative_title: "Alternative title:"
|
7
|
-
|
7
|
+
associated_with: "Associated with:"
|
8
8
|
bibliography: "Bibliography:"
|
9
9
|
biographical_historical: "Biographical/Historical:"
|
10
10
|
citation_reference: "Citation/Reference:"
|
11
11
|
collection: "Collection:"
|
12
12
|
contact: "Contact:"
|
13
|
+
constituent: "Contains:"
|
13
14
|
contributor: "Contributor:"
|
14
15
|
copyright: "Copyright:"
|
15
16
|
copyright_date: "Copyright date:"
|
@@ -27,6 +28,7 @@ en:
|
|
27
28
|
genre: "Genre:"
|
28
29
|
geo_extension: 'Format:'
|
29
30
|
handle: "Handle:"
|
31
|
+
host: "Appears in:"
|
30
32
|
identifier: "Identifier:"
|
31
33
|
imprint: "Imprint:"
|
32
34
|
isbn: "ISBN:"
|
data/lib/mods_display.rb
CHANGED
@@ -4,6 +4,7 @@ require 'mods_display/html'
|
|
4
4
|
require 'mods_display/model_extension'
|
5
5
|
require 'mods_display/country_codes'
|
6
6
|
require 'mods_display/relator_codes'
|
7
|
+
require 'mods_display/related_item_concerns'
|
7
8
|
require 'mods_display/configuration'
|
8
9
|
require 'mods_display/configuration/base'
|
9
10
|
require 'mods_display/configuration/access_condition'
|
@@ -32,6 +33,7 @@ require 'mods_display/fields/imprint'
|
|
32
33
|
require 'mods_display/fields/language'
|
33
34
|
require 'mods_display/fields/location'
|
34
35
|
require 'mods_display/fields/name'
|
36
|
+
require 'mods_display/fields/nested_related_item'
|
35
37
|
require 'mods_display/fields/note'
|
36
38
|
require 'mods_display/fields/related_item'
|
37
39
|
require 'mods_display/fields/resource_type'
|
@@ -70,6 +70,10 @@ module ModsDisplay
|
|
70
70
|
@related_item ||= ModsDisplay::Configuration::RelatedItem.new(&related_item || proc {})
|
71
71
|
end
|
72
72
|
|
73
|
+
def nested_related_item(&nested_related_item)
|
74
|
+
@nested_related_item ||= ModsDisplay::Configuration::Base.new(&nested_related_item || proc {})
|
75
|
+
end
|
76
|
+
|
73
77
|
def subject(&subject)
|
74
78
|
@subject ||= ModsDisplay::Configuration::Subject.new(&subject || proc {})
|
75
79
|
end
|
@@ -1,5 +1,23 @@
|
|
1
1
|
module ModsDisplay
|
2
2
|
class Contents < Field
|
3
|
+
def to_html
|
4
|
+
return nil if fields.empty? || @config.ignore?
|
5
|
+
output = ''
|
6
|
+
fields.each do |field|
|
7
|
+
next unless field.values.any? { |f| f && !f.empty? }
|
8
|
+
output << "<dt#{label_class} #{sanitized_field_title(field.label)}>#{field.label}</dt>"
|
9
|
+
output << "<dd#{value_class}>"
|
10
|
+
output << '<ul><li>'
|
11
|
+
# compress all values into a "--"-delimited string then split them up
|
12
|
+
output << field.values.join('--').split('--').map(&:strip).map do |val|
|
13
|
+
@config.link ? link_to_value(val.to_s) : link_urls_and_email(val.to_s)
|
14
|
+
end.join('</li><li>')
|
15
|
+
output << '</li></ul>'
|
16
|
+
output << '</dd>'
|
17
|
+
end
|
18
|
+
output
|
19
|
+
end
|
20
|
+
|
3
21
|
private
|
4
22
|
|
5
23
|
def displayLabel(element)
|
@@ -3,16 +3,17 @@ module ModsDisplay
|
|
3
3
|
include ModsDisplay::RelatorCodes
|
4
4
|
def fields
|
5
5
|
return_fields = @values.map do |value|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
person = if value.displayForm.length > 0
|
7
|
+
ModsDisplay::Name::Person.new(name: value.displayForm.text)
|
8
|
+
elsif !name_parts(value).empty?
|
9
|
+
ModsDisplay::Name::Person.new(name: name_parts(value))
|
10
|
+
end
|
11
|
+
# The person may have multiple roles, so we have to divide them up into an array
|
12
|
+
role_labels(value).collect do |role_label|
|
13
|
+
ModsDisplay::Values.new(label: displayLabel(value) || role_label, values: [person]) if person
|
12
14
|
end
|
13
|
-
|
14
|
-
|
15
|
-
collapse_fields(return_fields)
|
15
|
+
end.flatten.compact
|
16
|
+
collapse_roles(collapse_fields(return_fields))
|
16
17
|
end
|
17
18
|
|
18
19
|
def to_html
|
@@ -23,9 +24,7 @@ module ModsDisplay
|
|
23
24
|
output << "<dd#{value_class}>"
|
24
25
|
output << field.values.map do |val|
|
25
26
|
if @config.link
|
26
|
-
|
27
|
-
txt << " (#{val.roles.join(', ')})" if val.roles
|
28
|
-
txt
|
27
|
+
link_to_value(val.name)
|
29
28
|
else
|
30
29
|
val.to_s
|
31
30
|
end
|
@@ -37,12 +36,21 @@ module ModsDisplay
|
|
37
36
|
|
38
37
|
private
|
39
38
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
def collapse_roles(fields)
|
40
|
+
return [] if fields.blank?
|
41
|
+
|
42
|
+
label_order = fields.map(&:label)
|
43
|
+
results = consolidate_under_labels(fields)
|
44
|
+
label_keys = normalize_labels(label_order, results)
|
45
|
+
rebuild_fields_with_new_labels(label_keys, results)
|
46
|
+
end
|
47
|
+
|
48
|
+
def role_labels(element)
|
49
|
+
default_label = I18n.t('mods_display.associated_with')
|
50
|
+
return [default_label] unless element.role.present? && element.role.roleTerm.present?
|
51
|
+
element.role.roleTerm.collect do |role|
|
52
|
+
relator_codes[role.text.downcase] || role.text.capitalize || default_label
|
53
|
+
end.uniq
|
46
54
|
end
|
47
55
|
|
48
56
|
def role?(element)
|
@@ -54,12 +62,6 @@ module ModsDisplay
|
|
54
62
|
element.attributes['usage'].value == 'primary'
|
55
63
|
end
|
56
64
|
|
57
|
-
def author_or_creator_roles?(element)
|
58
|
-
['author', 'aut', 'creator', 'cre', ''].include?(element.role.roleTerm.text.downcase)
|
59
|
-
rescue
|
60
|
-
false
|
61
|
-
end
|
62
|
-
|
63
65
|
def name_parts(element)
|
64
66
|
output = ''
|
65
67
|
output << [unqualified_name_parts(element),
|
@@ -100,22 +102,6 @@ module ModsDisplay
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
103
|
-
def process_role(element)
|
104
|
-
return unless element.role.length > 0 && element.role.roleTerm.length > 0
|
105
|
-
if unencoded_role_term?(element)
|
106
|
-
unencoded_role_term(element)
|
107
|
-
else
|
108
|
-
element.role.roleTerm.map do |term|
|
109
|
-
next unless term.attributes['type'].respond_to?(:value) &&
|
110
|
-
term.attributes['type'].value == 'code' &&
|
111
|
-
term.attributes['authority'].respond_to?(:value) &&
|
112
|
-
term.attributes['authority'].value == 'marcrelator' &&
|
113
|
-
relator_codes.include?(term.text.strip)
|
114
|
-
relator_codes[term.text.strip]
|
115
|
-
end.compact
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
105
|
def unencoded_role_term(element)
|
120
106
|
roles = element.role.map do |role|
|
121
107
|
role.roleTerm.find do |term|
|
@@ -138,17 +124,49 @@ module ModsDisplay
|
|
138
124
|
end
|
139
125
|
end
|
140
126
|
|
127
|
+
# Consolidate all names under label headings
|
128
|
+
def consolidate_under_labels(fields)
|
129
|
+
results = {}
|
130
|
+
fields.each do |mdv| # ModsDisplay::Values
|
131
|
+
results[mdv.label] ||= []
|
132
|
+
results[mdv.label] << mdv.values
|
133
|
+
results[mdv.label].flatten!
|
134
|
+
end
|
135
|
+
results
|
136
|
+
end
|
137
|
+
|
138
|
+
# Normalize label headings by filtering out some punctuation and ending in :
|
139
|
+
def normalize_labels(label_order, results)
|
140
|
+
label_order.uniq.map do |k|
|
141
|
+
label = k.tr('.', '').tr(':', '').strip + ':'
|
142
|
+
if label != k
|
143
|
+
results[label] = results[k]
|
144
|
+
results.delete(k)
|
145
|
+
end
|
146
|
+
label
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def rebuild_fields_with_new_labels(label_keys, results)
|
151
|
+
# Build the new fields data, stripping out the roles within the Person classes
|
152
|
+
label_keys.uniq.map do |k|
|
153
|
+
mdv = ModsDisplay::Values.new({})
|
154
|
+
mdv.label = k
|
155
|
+
mdv.values = results[k].map do |person|
|
156
|
+
ModsDisplay::Name::Person.new(name: person.name)
|
157
|
+
end
|
158
|
+
mdv
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
141
162
|
class Person
|
142
|
-
attr_accessor :name
|
163
|
+
attr_accessor :name
|
143
164
|
def initialize(data)
|
144
165
|
@name = data[:name]
|
145
|
-
@roles = data[:roles] && !data[:roles].empty? ? data[:roles] : nil
|
146
166
|
end
|
147
167
|
|
148
168
|
def to_s
|
149
|
-
|
150
|
-
text << " (#{@roles.join(', ')})" if @roles
|
151
|
-
text
|
169
|
+
@name
|
152
170
|
end
|
153
171
|
end
|
154
172
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module ModsDisplay
|
2
|
+
##
|
3
|
+
# This class will hopefully take over for related item support more broadly.
|
4
|
+
# Currently there is behavior in RelatedItem and Collection that would need
|
5
|
+
# to be accounted for when adding nested metadata support.
|
6
|
+
class NestedRelatedItem < Field
|
7
|
+
include ModsDisplay::RelatedItemConcerns
|
8
|
+
|
9
|
+
def fields
|
10
|
+
return_fields = @values.map do |value|
|
11
|
+
next if related_item_is_a_collection?(value)
|
12
|
+
next unless render_nested_related_item?(value)
|
13
|
+
|
14
|
+
related_item_mods_object(value)
|
15
|
+
end.compact
|
16
|
+
collapse_fields(return_fields)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_html
|
20
|
+
return nil if fields.empty? || @config.ignore?
|
21
|
+
output = ''
|
22
|
+
fields.each do |field|
|
23
|
+
next unless field.values.any? { |f| f && !f.empty? }
|
24
|
+
output << "<dt#{label_class} #{sanitized_field_title(field.label)}>#{field.label}</dt>"
|
25
|
+
output << "<dd#{value_class}>"
|
26
|
+
output << '<ul class="mods_display_nested_related_items">'
|
27
|
+
output << field.values.map do |val|
|
28
|
+
"<li class='mods_display_nested_related_item open'>#{link_urls_and_email(val.to_s)}</li>"
|
29
|
+
end.join
|
30
|
+
output << '</ul>'
|
31
|
+
output << '</dd>'
|
32
|
+
end
|
33
|
+
output
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def related_item_mods_object(value)
|
39
|
+
mods = ::Stanford::Mods::Record.new.tap { |r| r.from_str("<mods>#{value.children.to_xml}</mods>", false) }
|
40
|
+
related_item = ModsDisplay::HTML.new(@config, mods, @klass)
|
41
|
+
|
42
|
+
ModsDisplay::Values.new(
|
43
|
+
label: related_item_label(value),
|
44
|
+
values: [[Array.wrap(related_item.title).first, related_item_body(related_item)].compact.join]
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def related_item_body(related_item)
|
49
|
+
return if related_item.body == '<dl></dl>'
|
50
|
+
related_item.body
|
51
|
+
end
|
52
|
+
|
53
|
+
def related_item_label(item)
|
54
|
+
return displayLabel(item) if displayLabel(item)
|
55
|
+
return I18n.t('mods_display.constituent') if related_item_is_a_constituent?(item)
|
56
|
+
|
57
|
+
I18n.t('mods_display.host')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,8 +1,11 @@
|
|
1
1
|
module ModsDisplay
|
2
2
|
class RelatedItem < Field
|
3
|
+
include ModsDisplay::RelatedItemConcerns
|
4
|
+
|
3
5
|
def fields
|
4
6
|
return_fields = @values.map do |value|
|
5
7
|
next if related_item_is_a_collection?(value)
|
8
|
+
next if render_nested_related_item?(value)
|
6
9
|
case
|
7
10
|
when related_item_is_a_location?(value)
|
8
11
|
process_location value
|
@@ -44,14 +47,6 @@ module ModsDisplay
|
|
44
47
|
item.note].flatten.compact.map!(&:text).map!(&:strip).join(' ')
|
45
48
|
end
|
46
49
|
|
47
|
-
def related_item_is_a_collection?(item)
|
48
|
-
item.respond_to?(:titleInfo) &&
|
49
|
-
item.respond_to?(:typeOfResource) &&
|
50
|
-
item.typeOfResource.attributes.length > 0 &&
|
51
|
-
item.typeOfResource.attributes.first.key?('collection') &&
|
52
|
-
item.typeOfResource.attributes.first['collection'].value == 'yes'
|
53
|
-
end
|
54
|
-
|
55
50
|
def related_item_is_a_location?(item)
|
56
51
|
!related_item_is_a_collection?(item) &&
|
57
52
|
!related_item_is_a_reference?(item) &&
|
@@ -45,17 +45,13 @@ module ModsDisplay
|
|
45
45
|
end
|
46
46
|
if @config.link && @config.hierarchical_link
|
47
47
|
if val.is_a?(ModsDisplay::Name::Person)
|
48
|
-
|
49
|
-
txt << " (#{val.roles.join(', ')})" if val.roles
|
50
|
-
sub_parts << txt
|
48
|
+
sub_parts << link_to_value(val.name, buffer.join(' '))
|
51
49
|
else
|
52
50
|
sub_parts << link_to_value(val, buffer.join(' '))
|
53
51
|
end
|
54
52
|
elsif @config.link
|
55
53
|
if val.is_a?(ModsDisplay::Name::Person)
|
56
|
-
|
57
|
-
txt << " (#{val.roles.join(', ')})" if val.roles
|
58
|
-
sub_parts << txt
|
54
|
+
sub_parts << link_to_value(val.name)
|
59
55
|
else
|
60
56
|
sub_parts << link_to_value(val.to_s)
|
61
57
|
end
|
data/lib/mods_display/html.rb
CHANGED
@@ -89,6 +89,7 @@ module ModsDisplay
|
|
89
89
|
:note,
|
90
90
|
:contact,
|
91
91
|
:collection,
|
92
|
+
:nestedRelatedItem,
|
92
93
|
:relatedItem,
|
93
94
|
:subject,
|
94
95
|
:identifier,
|
@@ -116,6 +117,7 @@ module ModsDisplay
|
|
116
117
|
note: :note,
|
117
118
|
contact: :note,
|
118
119
|
collection: :related_item,
|
120
|
+
nestedRelatedItem: :related_item,
|
119
121
|
relatedItem: :related_item,
|
120
122
|
subject: :subject,
|
121
123
|
identifier: :identifier,
|
@@ -127,7 +129,8 @@ module ModsDisplay
|
|
127
129
|
{ subTitle: :sub_title,
|
128
130
|
resourceType: :resource_type,
|
129
131
|
relatedItem: :related_item,
|
130
|
-
accessCondition: :access_condition
|
132
|
+
accessCondition: :access_condition,
|
133
|
+
nestedRelatedItem: :nested_related_item
|
131
134
|
}
|
132
135
|
end
|
133
136
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ModsDisplay
|
2
|
+
module RelatedItemConcerns
|
3
|
+
private
|
4
|
+
|
5
|
+
def render_nested_related_item?(item)
|
6
|
+
related_item_is_a_constituent?(item) || related_item_is_host?(item)
|
7
|
+
end
|
8
|
+
|
9
|
+
def related_item_is_a_collection?(item)
|
10
|
+
item.respond_to?(:titleInfo) &&
|
11
|
+
item.respond_to?(:typeOfResource) &&
|
12
|
+
!item.typeOfResource.attributes.empty? &&
|
13
|
+
item.typeOfResource.attributes.first.key?('collection') &&
|
14
|
+
item.typeOfResource.attributes.first['collection'].value == 'yes'
|
15
|
+
end
|
16
|
+
|
17
|
+
def related_item_is_a_constituent?(item)
|
18
|
+
item.attributes['type'].respond_to?(:value) &&
|
19
|
+
item.attributes['type'].value == 'constituent'
|
20
|
+
end
|
21
|
+
|
22
|
+
def related_item_is_host?(item)
|
23
|
+
item.attributes['type'].respond_to?(:value) &&
|
24
|
+
item.attributes['type'].value == 'host'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/mods_display/version.rb
CHANGED
data/mods_display.gemspec
CHANGED
@@ -21,4 +21,19 @@ describe ModsDisplay::Contents do
|
|
21
21
|
expect(mods_display_contents(@display_label).label).to eq('Special Label:')
|
22
22
|
end
|
23
23
|
end
|
24
|
+
context 'multi-valued contents' do
|
25
|
+
let(:toc) do
|
26
|
+
Stanford::Mods::Record.new.from_str(
|
27
|
+
'<mods><tableOfContents>Content Note 1 -- Content Note 2</tableOfContents></mods>', false
|
28
|
+
).tableOfContents
|
29
|
+
end
|
30
|
+
it 'should have one value with "--" marker' do
|
31
|
+
mdc = mods_display_contents(toc)
|
32
|
+
expect(mdc.fields.first.values).to eq ['Content Note 1 -- Content Note 2']
|
33
|
+
end
|
34
|
+
it 'should render as a list' do
|
35
|
+
html = mods_display_contents(toc).to_html
|
36
|
+
expect(html).to include '<dd><ul><li>Content Note 1</li><li>Content Note 2</li></ul></dd>'
|
37
|
+
end
|
38
|
+
end
|
24
39
|
end
|
data/spec/fields/name_spec.rb
CHANGED
@@ -19,6 +19,7 @@ describe ModsDisplay::Language do
|
|
19
19
|
@name = Stanford::Mods::Record.new.from_str(simple_name_fixture, false).plain_name
|
20
20
|
@blank_name = Stanford::Mods::Record.new.from_str(blank_name_fixture, false).plain_name
|
21
21
|
@primary_name = Stanford::Mods::Record.new.from_str(primary_name_fixture, false).plain_name
|
22
|
+
@primary_name_solo = Stanford::Mods::Record.new.from_str(primary_name_solo_fixture, false).plain_name
|
22
23
|
@contributor = Stanford::Mods::Record.new.from_str(contributor_fixture, false).plain_name
|
23
24
|
@encoded_role = Stanford::Mods::Record.new.from_str(encoded_role_fixture, false).plain_name
|
24
25
|
@mixed_role = Stanford::Mods::Record.new.from_str(mixed_role_fixture, false).plain_name
|
@@ -30,16 +31,27 @@ describe ModsDisplay::Language do
|
|
30
31
|
@complex_roles = Stanford::Mods::Record.new.from_str(complex_role_name_fixture, false).plain_name
|
31
32
|
@name_with_role = Stanford::Mods::Record.new.from_str(name_with_role_fixture, false).plain_name
|
32
33
|
@multiple_roles = Stanford::Mods::Record.new.from_str(multiple_roles_fixture, false).plain_name
|
34
|
+
@author_role = Stanford::Mods::Record.new.from_str(author_role_fixture, false).plain_name
|
35
|
+
@many_roles_and_names = Stanford::Mods::Record.new.from_str(many_roles_and_names_fixture, false).plain_name
|
36
|
+
@names_with_code_and_text_roles = Stanford::Mods::Record.new.from_str(names_with_code_and_text_roles_fixture, false).plain_name
|
33
37
|
end
|
38
|
+
let(:default_label) { 'Associated with:' }
|
39
|
+
|
34
40
|
describe 'label' do
|
35
41
|
it 'should default Author/Creator when no role is available' do
|
36
|
-
expect(mods_display_name(@name).fields.first.label).to eq(
|
42
|
+
expect(mods_display_name(@name).fields.first.label).to eq(default_label)
|
43
|
+
end
|
44
|
+
it "should label as role for primary authors with a role" do
|
45
|
+
expect(mods_display_name(@primary_name).fields.first.label).to eq('Lithographer:')
|
37
46
|
end
|
38
|
-
it "should label 'Author/Creator' for primary authors" do
|
39
|
-
expect(mods_display_name(@
|
47
|
+
it "should label 'Author/Creator' for non-role primary authors" do
|
48
|
+
expect(mods_display_name(@primary_name_solo).fields.first.label).to eq(default_label)
|
40
49
|
end
|
41
|
-
it 'should apply
|
42
|
-
expect(mods_display_name(@contributor).fields.first.label).to eq('
|
50
|
+
it 'should apply role labeling with text' do
|
51
|
+
expect(mods_display_name(@contributor).fields.first.label).to eq('Lithographer:')
|
52
|
+
end
|
53
|
+
it 'should apply role labeling with code' do
|
54
|
+
expect(mods_display_name(@author_role).fields.first.label).to eq('Author:')
|
43
55
|
end
|
44
56
|
end
|
45
57
|
|
@@ -71,7 +83,7 @@ describe ModsDisplay::Language do
|
|
71
83
|
it 'should collapse adjacent matching labels' do
|
72
84
|
fields = mods_display_name(@collapse_label).fields
|
73
85
|
expect(fields.length).to eq(1)
|
74
|
-
expect(fields.first.label).to eq(
|
86
|
+
expect(fields.first.label).to eq(default_label)
|
75
87
|
fields.first.values.each do |val|
|
76
88
|
expect(['John Doe', 'Jane Doe']).to include val.to_s
|
77
89
|
end
|
@@ -79,59 +91,64 @@ describe ModsDisplay::Language do
|
|
79
91
|
it 'should perseve order and separation of non-adjesent matching labels' do
|
80
92
|
fields = mods_display_name(@complex_labels).fields
|
81
93
|
|
82
|
-
expect(fields.length).to eq(
|
83
|
-
expect(fields.first.label).to eq(
|
84
|
-
expect(fields.first.values.length).to eq(
|
85
|
-
expect(fields.first.values.
|
94
|
+
expect(fields.length).to eq(2)
|
95
|
+
expect(fields.first.label).to eq(default_label)
|
96
|
+
expect(fields.first.values.length).to eq(3)
|
97
|
+
expect(fields.first.values.map(&:to_s)).to include 'John Doe', 'Jane Dough', 'John Dough'
|
86
98
|
|
87
|
-
expect(fields[1].label).to eq('
|
99
|
+
expect(fields[1].label).to eq('Lithographer:')
|
88
100
|
expect(fields[1].values.length).to eq(1)
|
89
101
|
expect(fields[1].values.first.name).to eq('Jane Doe')
|
90
|
-
expect(fields[1].values.first.roles).to eq(['lithographer'])
|
91
|
-
|
92
|
-
expect(fields.last.label).to eq('Author/Creator:')
|
93
|
-
expect(fields.last.values.length).to eq(2)
|
94
|
-
fields.last.values.each do |val|
|
95
|
-
expect(['Jane Dough', 'John Dough']).to include val.to_s
|
96
|
-
end
|
97
102
|
end
|
98
103
|
describe 'roles' do
|
99
104
|
it 'should get the role when present' do
|
100
105
|
fields = mods_display_name(@name_with_role).fields
|
101
106
|
expect(fields.length).to eq(1)
|
107
|
+
expect(fields.first.label).to eq('Depicted:')
|
102
108
|
expect(fields.first.values.length).to eq(1)
|
103
109
|
expect(fields.first.values.first).to be_a(ModsDisplay::Name::Person)
|
104
|
-
expect(fields.first.values.first.roles).to eq(['Depicted'])
|
105
110
|
end
|
106
111
|
it 'should decode encoded roleTerms when no text (or non-typed) roleTerm is available' do
|
107
112
|
fields = mods_display_name(@encoded_role).fields
|
108
113
|
expect(fields.length).to eq(1)
|
114
|
+
expect(fields.first.label).to eq('Lithographer:')
|
109
115
|
expect(fields.first.values.length).to eq(1)
|
110
|
-
expect(fields.first.values.first.to_s).to eq('John Doe
|
116
|
+
expect(fields.first.values.first.to_s).to eq('John Doe')
|
111
117
|
end
|
112
118
|
it "should get the type='text' role before an untyped role" do
|
113
119
|
fields = mods_display_name(@mixed_role).fields
|
114
|
-
expect(fields.length).to eq(
|
120
|
+
expect(fields.length).to eq(2)
|
121
|
+
expect(fields.first.label).to eq 'Publisher:'
|
122
|
+
expect(fields.last.label).to eq 'Engraver:'
|
115
123
|
expect(fields.first.values.length).to eq(1)
|
116
|
-
expect(fields.
|
124
|
+
expect(fields.last.values.length).to eq(1)
|
125
|
+
expect(fields.first.values.first.name).to eq fields.last.values.first.name
|
117
126
|
end
|
118
127
|
it 'should be handled correctly when there are more than one' do
|
119
128
|
fields = mods_display_name(@multiple_roles).fields
|
120
|
-
expect(fields.length).to eq
|
129
|
+
expect(fields.length).to eq 2
|
130
|
+
expect(fields.first.label).to eq 'Depicted:'
|
131
|
+
expect(fields.last.label).to eq 'Artist:'
|
121
132
|
expect(fields.first.values.length).to eq(1)
|
122
|
-
expect(fields.
|
133
|
+
expect(fields.last.values.length).to eq(1)
|
134
|
+
expect(fields.first.values.first.name).to eq fields.last.values.first.name
|
123
135
|
end
|
124
136
|
it 'should handle code and text roleTerms together correctly' do
|
125
137
|
fields = mods_display_name(@complex_roles).fields
|
126
|
-
expect(fields.length).to eq
|
127
|
-
expect(fields.first.
|
128
|
-
expect(fields.
|
138
|
+
expect(fields.length).to eq 2
|
139
|
+
expect(fields.first.label).to eq 'Depicted:'
|
140
|
+
expect(fields.last.label).to eq 'Depositor:'
|
141
|
+
expect(fields.first.values.first.name).to eq fields.last.values.first.name
|
129
142
|
end
|
130
|
-
it 'should
|
131
|
-
fields = mods_display_name(@
|
132
|
-
expect(fields.length).to eq
|
133
|
-
expect(fields.
|
134
|
-
|
143
|
+
it 'should handle consolidation of many roles and names' do
|
144
|
+
fields = mods_display_name(@many_roles_and_names).fields
|
145
|
+
expect(fields.length).to eq 6
|
146
|
+
expect(fields.map(&:label)).to eq %w[Associated\ with: Surveyor: Cartographer: Editor: Electrotyper: Lithographer:]
|
147
|
+
end
|
148
|
+
it 'should handle consolidation of names with both code and text roleTerms' do
|
149
|
+
fields = mods_display_name(@names_with_code_and_text_roles).fields
|
150
|
+
expect(fields.length).to eq 3
|
151
|
+
expect(fields.map(&:label)).to eq %w[Author: Printer: Donor:]
|
135
152
|
end
|
136
153
|
end
|
137
154
|
end
|
@@ -139,11 +156,11 @@ describe ModsDisplay::Language do
|
|
139
156
|
describe 'to_html' do
|
140
157
|
it 'should add the role to the name in parens' do
|
141
158
|
html = mods_display_name(@name_with_role).to_html
|
142
|
-
expect(html).to match(%r{<dd>John Doe
|
159
|
+
expect(html).to match(%r{<dd>John Doe</dd>})
|
143
160
|
end
|
144
|
-
it 'should
|
161
|
+
it 'should link the name and not the role if requested' do
|
145
162
|
html = mods_display_name_link(@name_with_role).to_html
|
146
|
-
expect(html).to match(%r{<dd><a href='.*\?John Doe'>John Doe</a
|
163
|
+
expect(html).to match(%r{<dd><a href='.*\?John Doe'>John Doe</a></dd>})
|
147
164
|
end
|
148
165
|
end
|
149
166
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ModsDisplay::NestedRelatedItem do
|
4
|
+
include RelatedItemFixtures
|
5
|
+
include NestedRelatedItemFixtures
|
6
|
+
|
7
|
+
let(:nested_related_item) do
|
8
|
+
described_class.new(
|
9
|
+
Stanford::Mods::Record.new.from_str(mods, false).related_item,
|
10
|
+
ModsDisplay::Configuration::Base.new,
|
11
|
+
double('controller')
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#label' do
|
16
|
+
subject(:label) { nested_related_item.fields.first.label }
|
17
|
+
|
18
|
+
context 'when a constituent' do
|
19
|
+
let(:mods) { multi_constituent_fixture }
|
20
|
+
|
21
|
+
it { is_expected.to eq 'Contains:' }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when a host' do
|
25
|
+
let(:mods) { related_item_host_fixture }
|
26
|
+
|
27
|
+
it { is_expected.to eq 'Appears in:' }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#fields' do
|
32
|
+
subject(:fields) { nested_related_item.fields }
|
33
|
+
|
34
|
+
context 'when an element that should be nested' do
|
35
|
+
let(:mods) { multi_constituent_fixture }
|
36
|
+
|
37
|
+
it 'has a field for each related item' do
|
38
|
+
expect(fields.length).to eq 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when a collection' do
|
43
|
+
let(:mods) { related_item_host_fixture }
|
44
|
+
|
45
|
+
it 'is not included' do
|
46
|
+
expect(fields.length).to eq 1 # This fixture has two host related items one of which is a collection
|
47
|
+
expect(fields.first.values.to_s).not_to include 'A collection'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when handled by another related_item class' do
|
52
|
+
let(:mods) { basic_related_item_fixture }
|
53
|
+
|
54
|
+
it { is_expected.to be_empty }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#to_html' do
|
59
|
+
subject(:html) { Capybara.string(nested_related_item.to_html) }
|
60
|
+
let(:mods) { related_item_host_fixture }
|
61
|
+
|
62
|
+
it 'renders an unordered list with an embedded dl containing the metadata of the related item' do
|
63
|
+
within(html.first('dd')) do |dd|
|
64
|
+
expect(dd).to have_css('ul.mods_display_nested_related_items')
|
65
|
+
within(dd.find('ul.mods_display_nested_related_items li')) do |li|
|
66
|
+
expect(li).to have_css('dl dt', text: 'Custom Notes:')
|
67
|
+
expect(li).to have_css('dl dd', text: 'A note content')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -6,6 +6,7 @@ end
|
|
6
6
|
|
7
7
|
describe ModsDisplay::RelatedItem do
|
8
8
|
include RelatedItemFixtures
|
9
|
+
include NestedRelatedItemFixtures
|
9
10
|
|
10
11
|
before(:all) do
|
11
12
|
@item = Stanford::Mods::Record.new.from_str(basic_related_item_fixture, false).related_item
|
@@ -16,7 +17,13 @@ describe ModsDisplay::RelatedItem do
|
|
16
17
|
@reference = Stanford::Mods::Record.new.from_str(related_item_reference_fixture, false).related_item
|
17
18
|
@blank_item = Stanford::Mods::Record.new.from_str(blank_related_item_fixture, false).related_item
|
18
19
|
@multi_items = Stanford::Mods::Record.new.from_str(multi_related_item_fixture, false).related_item
|
20
|
+
@constituent_items = Stanford::Mods::Record.new.from_str(multi_constituent_fixture, false).related_item
|
19
21
|
end
|
22
|
+
|
23
|
+
it 'excludes related items that will be rendered as a nested record' do
|
24
|
+
expect(mods_display_item(@constituent_items).fields).to be_empty
|
25
|
+
end
|
26
|
+
|
20
27
|
describe 'label' do
|
21
28
|
it 'should default to Related Item' do
|
22
29
|
expect(mods_display_item(@item).fields.first.label).to eq('Related item:')
|
data/spec/fields/subject_spec.rb
CHANGED
@@ -68,16 +68,15 @@ describe ModsDisplay::Subject do
|
|
68
68
|
expect(fields.length).to eq(1)
|
69
69
|
expect(fields.first.values.first.first).to be_a(ModsDisplay::Name::Person)
|
70
70
|
expect(fields.first.values.first.first.name).to eq('John Doe')
|
71
|
-
expect(fields.first.values.first.first.roles).to eq(['Depicted'])
|
72
71
|
end
|
73
72
|
it 'should link the name (and not the role) correctly' do
|
74
73
|
html = mods_display_subject(@name_subject).to_html
|
75
|
-
expect(html).to match(%r{<a href='.*\?John Doe'>John Doe</a>
|
74
|
+
expect(html).to match(%r{<a href='.*\?John Doe'>John Doe</a>})
|
76
75
|
expect(html).to match(%r{<a href='.*\?Anonymous People'>Anonymous People</a>})
|
77
76
|
end
|
78
77
|
it 'should linke the name (and not the role) correctly when linking hierarchicaly' do
|
79
78
|
html = mods_display_hierarchical_subject(@name_subject).to_html
|
80
|
-
expect(html).to match(%r{<a href='.*\?John Doe'>John Doe</a>
|
79
|
+
expect(html).to match(%r{<a href='.*\?John Doe'>John Doe</a>})
|
81
80
|
expect(html).to match(%r{<a href='.*\?John Doe Anonymous People'>Anonymous People</a>})
|
82
81
|
end
|
83
82
|
end
|
@@ -35,6 +35,16 @@ module NameFixtures
|
|
35
35
|
XML
|
36
36
|
end
|
37
37
|
|
38
|
+
def primary_name_solo_fixture
|
39
|
+
<<-XML
|
40
|
+
<mods>
|
41
|
+
<name usage='primary'>
|
42
|
+
<namePart>John Doe</namePart>
|
43
|
+
</name>
|
44
|
+
</mods>
|
45
|
+
XML
|
46
|
+
end
|
47
|
+
|
38
48
|
def contributor_fixture
|
39
49
|
<<-XML
|
40
50
|
<mods>
|
@@ -193,4 +203,196 @@ module NameFixtures
|
|
193
203
|
</mods>
|
194
204
|
XML
|
195
205
|
end
|
206
|
+
def author_role_fixture
|
207
|
+
<<-XML
|
208
|
+
<mods>
|
209
|
+
<name>
|
210
|
+
<namePart>John Doe</namePart>
|
211
|
+
<role>
|
212
|
+
<roleTerm type='code' authority='marcrelator'>aut</roleTerm>
|
213
|
+
</role>
|
214
|
+
</name>
|
215
|
+
</mods>
|
216
|
+
XML
|
217
|
+
end
|
218
|
+
def many_roles_and_names_fixture # from fs947tw3404
|
219
|
+
<<-XML
|
220
|
+
<mods>
|
221
|
+
<name type="corporate">
|
222
|
+
<namePart>United States Coast Survey</namePart>
|
223
|
+
</name>
|
224
|
+
<name type="personal">
|
225
|
+
<namePart>Lawson, J. S.</namePart>
|
226
|
+
<role>
|
227
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
228
|
+
</role>
|
229
|
+
</name>
|
230
|
+
<name type="personal">
|
231
|
+
<namePart>Wilkes, Charles</namePart>
|
232
|
+
<namePart type="date">1798-1877</namePart>
|
233
|
+
<role>
|
234
|
+
<roleTerm type="text">cartographer.</roleTerm>
|
235
|
+
</role>
|
236
|
+
</name>
|
237
|
+
<name type="personal">
|
238
|
+
<namePart>Jones, John P. (John Percival)</namePart>
|
239
|
+
<namePart type="date">1829-1912</namePart>
|
240
|
+
<role>
|
241
|
+
<roleTerm type="text">cartographer.</roleTerm>
|
242
|
+
</role>
|
243
|
+
</name>
|
244
|
+
<name type="personal">
|
245
|
+
<namePart>Patterson, C. P. (Carlile Pollock)</namePart>
|
246
|
+
<namePart type="date">1816-1881</namePart>
|
247
|
+
<role>
|
248
|
+
<roleTerm type="text">cartographer.</roleTerm>
|
249
|
+
</role>
|
250
|
+
</name>
|
251
|
+
<name type="personal">
|
252
|
+
<namePart>Schott, C. A.</namePart>
|
253
|
+
<role>
|
254
|
+
<roleTerm type="text">editor.</roleTerm>
|
255
|
+
</role>
|
256
|
+
</name>
|
257
|
+
<name type="personal">
|
258
|
+
<namePart>Cutts, R. D. (Richard Dominicus)</namePart>
|
259
|
+
<namePart type="date">1817-1883</namePart>
|
260
|
+
<role>
|
261
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
262
|
+
</role>
|
263
|
+
</name>
|
264
|
+
<name type="personal">
|
265
|
+
<namePart>Gilbert, J. J.</namePart>
|
266
|
+
<role>
|
267
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
268
|
+
</role>
|
269
|
+
</name>
|
270
|
+
<name type="personal">
|
271
|
+
<namePart>Rockwell, Cleveland</namePart>
|
272
|
+
<namePart type="date">1837-1907</namePart>
|
273
|
+
<role>
|
274
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
275
|
+
</role>
|
276
|
+
</name>
|
277
|
+
<name type="personal">
|
278
|
+
<namePart>Coffin, G. W.</namePart>
|
279
|
+
<role>
|
280
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
281
|
+
</role>
|
282
|
+
</name>
|
283
|
+
<name type="personal">
|
284
|
+
<namePart>Cordell, E.</namePart>
|
285
|
+
<role>
|
286
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
287
|
+
</role>
|
288
|
+
</name>
|
289
|
+
<name type="personal">
|
290
|
+
<namePart>Davidson, George</namePart>
|
291
|
+
<namePart type="date">1825-1911</namePart>
|
292
|
+
<role>
|
293
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
294
|
+
</role>
|
295
|
+
</name>
|
296
|
+
<name type="personal">
|
297
|
+
<namePart>Eimbeck, W.</namePart>
|
298
|
+
<role>
|
299
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
300
|
+
</role>
|
301
|
+
</name>
|
302
|
+
<name type="personal">
|
303
|
+
<namePart>Hilgard, J. E. (Julius Erasmus)</namePart>
|
304
|
+
<namePart type="date">1825-1891</namePart>
|
305
|
+
<role>
|
306
|
+
<roleTerm type="text">editor.</roleTerm>
|
307
|
+
</role>
|
308
|
+
</name>
|
309
|
+
<name type="personal">
|
310
|
+
<namePart>Bache, A. D. (Alexander Dallas)</namePart>
|
311
|
+
<namePart type="date">1806-1867</namePart>
|
312
|
+
<role>
|
313
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
314
|
+
</role>
|
315
|
+
</name>
|
316
|
+
<name type="personal">
|
317
|
+
<namePart>Rodgers, A. F.</namePart>
|
318
|
+
<role>
|
319
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
320
|
+
</role>
|
321
|
+
</name>
|
322
|
+
<name type="personal">
|
323
|
+
<namePart>Harrison, A. M. (Alexander Medina)</namePart>
|
324
|
+
<namePart type="date">1829-1881</namePart>
|
325
|
+
<role>
|
326
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
327
|
+
</role>
|
328
|
+
</name>
|
329
|
+
<name type="personal">
|
330
|
+
<namePart>Alden, James</namePart>
|
331
|
+
<namePart type="date">1810-1877</namePart>
|
332
|
+
<role>
|
333
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
334
|
+
</role>
|
335
|
+
</name>
|
336
|
+
<name type="personal">
|
337
|
+
<namePart>Mathiot, G.</namePart>
|
338
|
+
<role>
|
339
|
+
<roleTerm type="text">electrotyper.</roleTerm>
|
340
|
+
</role>
|
341
|
+
</name>
|
342
|
+
<name type="personal">
|
343
|
+
<namePart>Harrison, A. M. (Alexander Medina)</namePart>
|
344
|
+
<namePart type="date">1829-1881</namePart>
|
345
|
+
<role>
|
346
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
347
|
+
</role>
|
348
|
+
</name>
|
349
|
+
<name type="corporate">
|
350
|
+
<namePart>U.S. Coast and Geodetic Survey</namePart>
|
351
|
+
<role>
|
352
|
+
<roleTerm type="text">surveyor.</roleTerm>
|
353
|
+
</role>
|
354
|
+
</name>
|
355
|
+
<name type="corporate">
|
356
|
+
<namePart>N.Y. Lithographing, Engraving & Printing Co</namePart>
|
357
|
+
<role>
|
358
|
+
<roleTerm type="text">lithographer.</roleTerm>
|
359
|
+
</role>
|
360
|
+
</name>
|
361
|
+
</mods>
|
362
|
+
XML
|
363
|
+
end
|
364
|
+
def names_with_code_and_text_roles_fixture # from vn199zb9806
|
365
|
+
<<-XML
|
366
|
+
<mods>
|
367
|
+
<name type="personal" usage="primary" authority="naf" authorityURI="http://id.loc.gov/authorities/names" valueURI="http://id.loc.gov/authorities/names/n78095825" nameTitleGroup="1">
|
368
|
+
<namePart>Johnson, Samuel, 1709-1784</namePart>
|
369
|
+
<role>
|
370
|
+
<roleTerm type="code" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/aut">aut</roleTerm>
|
371
|
+
<roleTerm type="text" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/aut">author</roleTerm>
|
372
|
+
</role>
|
373
|
+
</name>
|
374
|
+
<name type="personal" authority="naf" authorityURI="http://id.loc.gov/authorities/names" valueURI="http://id.loc.gov/authorities/names/n78095825">
|
375
|
+
<namePart>Johnson, Samuel, 1709-1784</namePart>
|
376
|
+
<role>
|
377
|
+
<roleTerm type="code" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/prt">prt</roleTerm>
|
378
|
+
<roleTerm type="text" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/prt">printer</roleTerm>
|
379
|
+
</role>
|
380
|
+
</name>
|
381
|
+
<name type="personal">
|
382
|
+
<namePart>Downing, Donn Faber</namePart>
|
383
|
+
<role>
|
384
|
+
<roleTerm type="code" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/dnr">dnr</roleTerm>
|
385
|
+
<roleTerm type="text" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/dnr">donor</roleTerm>
|
386
|
+
</role>
|
387
|
+
</name>
|
388
|
+
<name type="personal">
|
389
|
+
<namePart>Sanders, Letitia Leigh</namePart>
|
390
|
+
<role>
|
391
|
+
<roleTerm type="code" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/dnr">dnr</roleTerm>
|
392
|
+
<roleTerm type="text" authority="marcrelator" authorityURI="http://id.loc.gov/vocabulary/relators" valueURI="http://id.loc.gov/vocabulary/relators/dnr">donor</roleTerm>
|
393
|
+
</role>
|
394
|
+
</name>
|
395
|
+
</mods>
|
396
|
+
XML
|
397
|
+
end
|
196
398
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module NestedRelatedItemFixtures
|
2
|
+
def related_item_host_fixture
|
3
|
+
<<-XML
|
4
|
+
<mods>
|
5
|
+
<relatedItem type="host">
|
6
|
+
<titleInfo>A host type related item</titleInfo>
|
7
|
+
<note displayLabel="Custom Notes">A note content</note>
|
8
|
+
</relatedItem>
|
9
|
+
<relatedItem type="host">
|
10
|
+
<titleInfo>A collection</titleInfo>
|
11
|
+
<typeOfResource collection="yes" />
|
12
|
+
</relatedItem>
|
13
|
+
</mods>
|
14
|
+
XML
|
15
|
+
end
|
16
|
+
|
17
|
+
def multi_constituent_fixture
|
18
|
+
<<-XML
|
19
|
+
<mods>
|
20
|
+
<relatedItem type="constituent">
|
21
|
+
<titleInfo>
|
22
|
+
<title>Polychronicon (epitome and continuation to 1429)</title>
|
23
|
+
<partNumber>ff. 1r - 29v</partNumber>
|
24
|
+
</titleInfo>
|
25
|
+
<titleInfo displayLabel="Nasmith Title" type="alternative">
|
26
|
+
<title>Epitome chronicae Cicestrensis, sed extractum e Polychronico, usque ad annum Christi 1429</title>
|
27
|
+
</titleInfo>
|
28
|
+
<name type="personal">
|
29
|
+
<namePart>Ranulf Higden OSB</namePart>
|
30
|
+
<role>
|
31
|
+
<roleTerm authority="marcrelator" type="text" valueURI="http://id.loc.gov/vocabulary/relators/aut">author</roleTerm>
|
32
|
+
</role>
|
33
|
+
</name>
|
34
|
+
<note>Dates are marked in the margin. Ends with the coronation of Henry VI at St Denis</note>
|
35
|
+
<note displayLabel="Incipit" type="incipit">Ieronimus ad eugenium in epistola 43a dicit quod decime leguntur primum date ab abraham</note>
|
36
|
+
<note displayLabel="Explicit" type="explicit">videlicet nono die mensis decembris ano etatis sue 10o</note>
|
37
|
+
</relatedItem>
|
38
|
+
<relatedItem type="constituent">
|
39
|
+
<titleInfo>
|
40
|
+
<title>Gesta regum ad Henricum VI</title>
|
41
|
+
<partNumber>ff. 30r - 53r</partNumber>
|
42
|
+
</titleInfo>
|
43
|
+
<titleInfo displayLabel="Nasmith Title" type="alternative">
|
44
|
+
<title>Breviarium historiae Angliae ad annum quartum Henrici IV. viz. 1402</title>
|
45
|
+
</titleInfo>
|
46
|
+
<titleInfo displayLabel="M.R. James Title" type="alternative">
|
47
|
+
<title>Breuiarium</title>
|
48
|
+
</titleInfo>
|
49
|
+
<name type="personal">
|
50
|
+
<namePart>Thomas Harsfield</namePart>
|
51
|
+
<role>
|
52
|
+
<roleTerm authority="marcrelator" type="text" valueURI="http://id.loc.gov/vocabulary/relators/aut">author</roleTerm>
|
53
|
+
</role>
|
54
|
+
</name>
|
55
|
+
<note>Another hand. Begins with 19 lines</note>
|
56
|
+
<note displayLabel="Incipit 1" type="incipit">Albion est terra constans in finibus orbis</note>
|
57
|
+
<note displayLabel="Explicit 1" type="explicit">Petrus pictauis dat cistrensis monachusque</note>
|
58
|
+
<note displayLabel="Incipit 2" type="incipit">Et quia confrater carissime non solum audiendo sacre scripture verbis aurem sedulus auditor accomodatur (!) tenetur</note>
|
59
|
+
<note displayLabel="Explicit 2" type="explicit">Tempore huius regis Owynus quidam Wallensis erigens se in principem Wallie toto vite sue tempore cum Wallensibus rebellauit</note>
|
60
|
+
</relatedItem>
|
61
|
+
</mods>
|
62
|
+
XML
|
63
|
+
end
|
64
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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.5.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:
|
11
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stanford-mods
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: capybara
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
description: MODS Display is a gem to centralize the display logic of MODS medadata.
|
84
112
|
email:
|
85
113
|
- jessie.keck@gmail.com
|
@@ -127,6 +155,7 @@ files:
|
|
127
155
|
- lib/mods_display/fields/language.rb
|
128
156
|
- lib/mods_display/fields/location.rb
|
129
157
|
- lib/mods_display/fields/name.rb
|
158
|
+
- lib/mods_display/fields/nested_related_item.rb
|
130
159
|
- lib/mods_display/fields/note.rb
|
131
160
|
- lib/mods_display/fields/related_item.rb
|
132
161
|
- lib/mods_display/fields/resource_type.rb
|
@@ -136,6 +165,7 @@ files:
|
|
136
165
|
- lib/mods_display/fields/values.rb
|
137
166
|
- lib/mods_display/html.rb
|
138
167
|
- lib/mods_display/model_extension.rb
|
168
|
+
- lib/mods_display/related_item_concerns.rb
|
139
169
|
- lib/mods_display/relator_codes.rb
|
140
170
|
- lib/mods_display/version.rb
|
141
171
|
- mods_display.gemspec
|
@@ -158,6 +188,7 @@ files:
|
|
158
188
|
- spec/fields/language_spec.rb
|
159
189
|
- spec/fields/location_spec.rb
|
160
190
|
- spec/fields/name_spec.rb
|
191
|
+
- spec/fields/nested_related_item_spec.rb
|
161
192
|
- spec/fields/note_spec.rb
|
162
193
|
- spec/fields/related_item_spec.rb
|
163
194
|
- spec/fields/resource_type_spec.rb
|
@@ -168,6 +199,7 @@ files:
|
|
168
199
|
- spec/fixtures/cartographics_fixtures.rb
|
169
200
|
- spec/fixtures/imprint_fixtures.rb
|
170
201
|
- spec/fixtures/name_fixtures.rb
|
202
|
+
- spec/fixtures/nested_realted_items_fixtures.rb
|
171
203
|
- spec/fixtures/related_item_fixtures.rb
|
172
204
|
- spec/fixtures/subjects_fixtures.rb
|
173
205
|
- spec/fixtures/title_fixtures.rb
|
@@ -195,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
227
|
version: '0'
|
196
228
|
requirements: []
|
197
229
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.
|
230
|
+
rubygems_version: 2.6.11
|
199
231
|
signing_key:
|
200
232
|
specification_version: 4
|
201
233
|
summary: The MODS Display gem allows implementers to configure a customized display
|
@@ -221,6 +253,7 @@ test_files:
|
|
221
253
|
- spec/fields/language_spec.rb
|
222
254
|
- spec/fields/location_spec.rb
|
223
255
|
- spec/fields/name_spec.rb
|
256
|
+
- spec/fields/nested_related_item_spec.rb
|
224
257
|
- spec/fields/note_spec.rb
|
225
258
|
- spec/fields/related_item_spec.rb
|
226
259
|
- spec/fields/resource_type_spec.rb
|
@@ -231,6 +264,7 @@ test_files:
|
|
231
264
|
- spec/fixtures/cartographics_fixtures.rb
|
232
265
|
- spec/fixtures/imprint_fixtures.rb
|
233
266
|
- spec/fixtures/name_fixtures.rb
|
267
|
+
- spec/fixtures/nested_realted_items_fixtures.rb
|
234
268
|
- spec/fixtures/related_item_fixtures.rb
|
235
269
|
- spec/fixtures/subjects_fixtures.rb
|
236
270
|
- spec/fixtures/title_fixtures.rb
|