mods_display 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -2
- data/config/locales/en.yml +67 -0
- data/lib/mods_display.rb +8 -1
- data/lib/mods_display/fields/abstract.rb +1 -1
- data/lib/mods_display/fields/access_condition.rb +5 -5
- data/lib/mods_display/fields/audience.rb +1 -1
- data/lib/mods_display/fields/cartographics.rb +1 -1
- data/lib/mods_display/fields/collection.rb +1 -1
- data/lib/mods_display/fields/contact.rb +1 -1
- data/lib/mods_display/fields/contents.rb +1 -1
- data/lib/mods_display/fields/description.rb +3 -3
- data/lib/mods_display/fields/field.rb +6 -2
- data/lib/mods_display/fields/format.rb +5 -2
- data/lib/mods_display/fields/genre.rb +1 -1
- data/lib/mods_display/fields/identifier.rb +20 -20
- data/lib/mods_display/fields/imprint.rb +9 -9
- data/lib/mods_display/fields/language.rb +1 -1
- data/lib/mods_display/fields/location.rb +5 -5
- data/lib/mods_display/fields/name.rb +3 -3
- data/lib/mods_display/fields/note.rb +11 -12
- data/lib/mods_display/fields/related_item.rb +3 -3
- data/lib/mods_display/fields/resource_type.rb +1 -1
- data/lib/mods_display/fields/subject.rb +2 -2
- data/lib/mods_display/fields/title.rb +5 -5
- data/lib/mods_display/version.rb +1 -1
- data/mods_display.gemspec +1 -0
- data/spec/fields/abstract_spec.rb +1 -1
- data/spec/fields/access_condition_spec.rb +1 -1
- data/spec/fields/audience_spec.rb +2 -2
- data/spec/fields/collection_spec.rb +2 -2
- data/spec/fields/contents_spec.rb +2 -2
- data/spec/fields/description_spec.rb +4 -4
- data/spec/fields/genre_spec.rb +2 -2
- data/spec/fields/identifier_spec.rb +7 -7
- data/spec/fields/imprint_spec.rb +11 -11
- data/spec/fields/language_spec.rb +1 -1
- data/spec/fields/location_spec.rb +6 -6
- data/spec/fields/name_spec.rb +7 -7
- data/spec/fields/note_spec.rb +6 -6
- data/spec/fields/related_item_spec.rb +5 -5
- data/spec/fields/resource_type_spec.rb +2 -2
- data/spec/fields/sub_title_spec.rb +1 -1
- data/spec/fields/subject_spec.rb +3 -3
- data/spec/fields/title_spec.rb +8 -8
- data/spec/integration/html_spec.rb +20 -2
- data/spec/spec_helper.rb +6 -0
- data/spec/test_fr.yml +3 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7405311ccd79996582dd2eacb5a4aed58f01bc10
|
4
|
+
data.tar.gz: 8239610c70f063e06bdf0b27dd1a11d21824b050
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0db38505cefc90acce173c4092574fe50bd7781326f5aff9b490a2491c3a6795641a3bb5055a72b0da6a202e48c62b8a798b9ef10d07a9286e1e0c491a6a2da6
|
7
|
+
data.tar.gz: 66abdd1b57edd01c590c4cc3e821d14db40cc377b24d737be32116f67f9363556157b1f625e5eaf0c4514be975489f2825acc5775bd2b66dc323528b6157325d
|
data/README.md
CHANGED
@@ -168,14 +168,22 @@ When getting JUST the main (first) title out of the metadata, it will be useful
|
|
168
168
|
You can also access the array of ModsDisplay::Values objects for a given class directly by calling the name of the class. The class names are not always intuitive for public consumption so you may want to check the code the particular method to call.
|
169
169
|
|
170
170
|
render_mods_display(@model).abstract
|
171
|
-
=> [#<ModsDisplay::Values @label="Abstract", @values=["Hey. I'm an abstract."]>]
|
171
|
+
=> [#<ModsDisplay::Values @label="Abstract:", @values=["Hey. I'm an abstract."]>]
|
172
172
|
|
173
173
|
Given that this semantics that we're concerned with here are more about titles and data construction rather than XML it may be required that you find something by the label. A common example of this is the imprint class. The imprint class can retun other publication data that is not the imprint statement. You'll want to select (using your favorite enumerable method) the element in the array that is an imprint.
|
174
174
|
|
175
175
|
imprint = render_mods_display(@model).imprint.find do |data|
|
176
|
-
data.label == "Imprint"
|
176
|
+
data.label == "Imprint:"
|
177
177
|
end.values
|
178
178
|
|
179
|
+
## Release/Upgrade Notes
|
180
|
+
|
181
|
+
#### v0.3.0
|
182
|
+
|
183
|
+
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.
|
184
|
+
|
185
|
+
Given that fact, you will want to update any pre 0.3.0 code that searches for elements by label in a way that would fail with the presence of a colon.
|
186
|
+
|
179
187
|
## Contributing
|
180
188
|
|
181
189
|
1. Fork it
|
@@ -0,0 +1,67 @@
|
|
1
|
+
en:
|
2
|
+
mods_display:
|
3
|
+
abbreviated_title: "Abbreviated title:"
|
4
|
+
abstract: "Abstract:"
|
5
|
+
access_condition: "Access condition:"
|
6
|
+
alternative_title: "Alternative title:"
|
7
|
+
author_creator: "Author/Creator:"
|
8
|
+
bibliography: "Bibliography:"
|
9
|
+
biographical_historical: "Biographical/Historical:"
|
10
|
+
citation_reference: "Citation/Reference:"
|
11
|
+
collection: "Collection:"
|
12
|
+
contact: "Contact:"
|
13
|
+
contributor: "Contributor:"
|
14
|
+
copyright: "Copyright:"
|
15
|
+
copyright_date: "Copyright date:"
|
16
|
+
creation_production_credits: "Creation/Production credits:"
|
17
|
+
date_captured: "Date captured:"
|
18
|
+
date_created: "Date created:"
|
19
|
+
date_modified: "Date modified:"
|
20
|
+
date_sequential_designation: "Date/Sequential designation:"
|
21
|
+
date_valid: "Date valid:"
|
22
|
+
digital_origin: "Digital origin:"
|
23
|
+
doi: "DOI:"
|
24
|
+
format: "Format:"
|
25
|
+
frequency: "Frequency:"
|
26
|
+
genre: "Genre:"
|
27
|
+
handle: "Handle:"
|
28
|
+
identifier: "Identifier:"
|
29
|
+
imprint: "Imprint:"
|
30
|
+
isbn: "ISBN:"
|
31
|
+
ismn: "ISMN:"
|
32
|
+
isrc: "ISRC:"
|
33
|
+
issn: "ISSN:"
|
34
|
+
issuance: "Issuance:"
|
35
|
+
issue_number: "Issue number:"
|
36
|
+
language: "Language:"
|
37
|
+
lccn: "LCCN:"
|
38
|
+
location: "Location:"
|
39
|
+
map_data: "Map data:"
|
40
|
+
matrix_number: "Matric number:"
|
41
|
+
music_plate: "Music plate:"
|
42
|
+
music_publisher: "Music publisher:"
|
43
|
+
note: "Note:"
|
44
|
+
oclc: "OCLC:"
|
45
|
+
physical_description: "Physical description:"
|
46
|
+
place: "Place:"
|
47
|
+
preferred_citation: "Preferred citation:"
|
48
|
+
publications: "Publications:"
|
49
|
+
publisher: "Publisher:"
|
50
|
+
referenced_by: "Referenced by:"
|
51
|
+
references: "References:"
|
52
|
+
related_item: "Related item:"
|
53
|
+
repository: "Repository:"
|
54
|
+
restriction_on_access: "Restriction on access:"
|
55
|
+
sici: "SICI:"
|
56
|
+
statement_of_responsibility: "Statement of responsibility:"
|
57
|
+
stock_number: "Stock number:"
|
58
|
+
subject: "Subject:"
|
59
|
+
table_of_contents: "Table of contents:"
|
60
|
+
target_audience: "Target audience:"
|
61
|
+
title: "Title:"
|
62
|
+
translated_title: "Translated title:"
|
63
|
+
type_of_resource: "Type of resource:"
|
64
|
+
uniform_title: "Uniform title:"
|
65
|
+
upc: "UPC:"
|
66
|
+
use_and_reproduction: "Use and reproduction:"
|
67
|
+
videorecording_identifier: "Videorecording identifier:"
|
data/lib/mods_display.rb
CHANGED
@@ -36,4 +36,11 @@ require "mods_display/fields/resource_type"
|
|
36
36
|
require "mods_display/fields/subject"
|
37
37
|
require "mods_display/fields/sub_title"
|
38
38
|
require "mods_display/fields/title"
|
39
|
-
require "mods_display/fields/values"
|
39
|
+
require "mods_display/fields/values"
|
40
|
+
|
41
|
+
require "i18n"
|
42
|
+
require "i18n/backend/fallbacks"
|
43
|
+
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
|
44
|
+
I18n.load_path += Dir["#{File.expand_path('../..', __FILE__)}/config/locales/*.yml"]
|
45
|
+
I18n.default_locale = :en
|
46
|
+
I18n.backend.load_translations
|
@@ -52,7 +52,7 @@ class ModsDisplay::AccessCondition < ModsDisplay::Field
|
|
52
52
|
if access_labels.has_key?(type)
|
53
53
|
return access_labels[type]
|
54
54
|
end
|
55
|
-
|
55
|
+
I18n.t('mods_display.access_condition')
|
56
56
|
end
|
57
57
|
|
58
58
|
def normalize_type(element)
|
@@ -64,10 +64,10 @@ class ModsDisplay::AccessCondition < ModsDisplay::Field
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def access_labels
|
67
|
-
{"useandreproduction" =>
|
68
|
-
"restrictiononaccess" =>
|
69
|
-
"copyright" =>
|
70
|
-
"license" =>
|
67
|
+
{"useandreproduction" => I18n.t('mods_display.use_and_reproduction'),
|
68
|
+
"restrictiononaccess" => I18n.t('mods_display.restriction_on_access'),
|
69
|
+
"copyright" => I18n.t('mods_display.copyright'),
|
70
|
+
"license" => I18n.t('mods_display.license')
|
71
71
|
}
|
72
72
|
end
|
73
73
|
end
|
@@ -10,7 +10,7 @@ class ModsDisplay::Cartographics < ModsDisplay::Field
|
|
10
10
|
projection = field.projection.empty? ? nil : field.projection.text
|
11
11
|
coordinates = field.coordinates.empty? ? nil : field.coordinates.text
|
12
12
|
post_scale = [projection, coordinates].compact.length > 0 ? [projection, coordinates].compact.join(" ") : nil
|
13
|
-
return_fields << ModsDisplay::Values.new({:label => (displayLabel(field) || label ||
|
13
|
+
return_fields << ModsDisplay::Values.new({:label => (displayLabel(field) || label || I18n.t('mods_display.map_data')),
|
14
14
|
:values => [[scale, post_scale].compact.join(" ; ")]})
|
15
15
|
end
|
16
16
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class ModsDisplay::Contact < ModsDisplay::Field
|
2
2
|
def fields
|
3
3
|
return_fields = contact_fields.map do |value|
|
4
|
-
ModsDisplay::Values.new(:label => displayLabel(value) ||
|
4
|
+
ModsDisplay::Values.new(:label => displayLabel(value) || I18n.t('mods_display.contact'), :values => [value.text])
|
5
5
|
end
|
6
6
|
collapse_fields(return_fields)
|
7
7
|
end
|
@@ -8,7 +8,7 @@ class ModsDisplay::Description < ModsDisplay::Field
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def description_label(element)
|
11
|
-
label || displayLabel(element) || labels[element.name.to_sym] ||
|
11
|
+
label || displayLabel(element) || labels[element.name.to_sym] || I18n.t('mods_display.physical_description')
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -20,8 +20,8 @@ class ModsDisplay::Description < ModsDisplay::Field
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def labels
|
23
|
-
{:digitalOrigin =>
|
24
|
-
:note =>
|
23
|
+
{:digitalOrigin => I18n.t('mods_display.digital_origin'),
|
24
|
+
:note => I18n.t('mods_display.note')
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
@@ -23,7 +23,7 @@ class ModsDisplay::Field
|
|
23
23
|
output = ""
|
24
24
|
fields.each do |field|
|
25
25
|
if field.values.any?{|f| f && !f.empty? }
|
26
|
-
output << "<dt#{label_class}
|
26
|
+
output << "<dt#{label_class} #{sanitized_field_title(field.label)}>#{field.label}</dt>"
|
27
27
|
output << "<dd#{value_class}>"
|
28
28
|
output << field.values.map do |val|
|
29
29
|
@config.link ? link_to_value(val.to_s) : link_urls_and_email(val.to_s)
|
@@ -57,10 +57,14 @@ class ModsDisplay::Field
|
|
57
57
|
def displayLabel(element)
|
58
58
|
if (element.respond_to?(:attributes) and
|
59
59
|
element.attributes["displayLabel"].respond_to?(:value))
|
60
|
-
element.attributes["displayLabel"].value
|
60
|
+
"#{element.attributes["displayLabel"].value}:"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
def sanitized_field_title(label)
|
65
|
+
"title='#{label.gsub(/:$/,'').strip}'"
|
66
|
+
end
|
67
|
+
|
64
68
|
def replace_tokens(object, value)
|
65
69
|
object = object.dup
|
66
70
|
if object.is_a?(Hash)
|
@@ -11,11 +11,11 @@ class ModsDisplay::Format < ModsDisplay::Field
|
|
11
11
|
unless @values.physical_description.nil?
|
12
12
|
@values.physical_description.each do |description|
|
13
13
|
unless description.form.nil? or description.form.empty?
|
14
|
-
return_fields << ModsDisplay::Values.new(:label => displayLabel(description) ||
|
14
|
+
return_fields << ModsDisplay::Values.new(:label => displayLabel(description) || format_label,
|
15
15
|
:values => [description.form.map{|f| f.text.strip }.uniq.join(", ")])
|
16
16
|
end
|
17
17
|
unless description.extent.nil? or description.extent.empty?
|
18
|
-
return_fields << ModsDisplay::Values.new(:label => displayLabel(description) ||
|
18
|
+
return_fields << ModsDisplay::Values.new(:label => displayLabel(description) || format_label,
|
19
19
|
:values => [description.extent.map{|e| e.text }.join(", ")])
|
20
20
|
end
|
21
21
|
end
|
@@ -36,4 +36,7 @@ class ModsDisplay::Format < ModsDisplay::Field
|
|
36
36
|
format.strip.downcase.gsub(/\/|\\|\s+/, "_")
|
37
37
|
end
|
38
38
|
|
39
|
+
def format_label
|
40
|
+
I18n.t('mods_display.format')
|
41
|
+
end
|
39
42
|
end
|
@@ -11,30 +11,30 @@ class ModsDisplay::Identifier < ModsDisplay::Field
|
|
11
11
|
|
12
12
|
def identifier_label(element)
|
13
13
|
if element.attributes["type"].respond_to?(:value)
|
14
|
-
return identifier_labels[element.attributes["type"].value] || element.attributes["type"].value
|
14
|
+
return identifier_labels[element.attributes["type"].value] || "#{element.attributes["type"].value}:"
|
15
15
|
end
|
16
|
-
|
16
|
+
I18n.t('mods_display.identifier')
|
17
17
|
end
|
18
18
|
|
19
19
|
def identifier_labels
|
20
|
-
{"local" =>
|
21
|
-
"isbn" =>
|
22
|
-
"issn" =>
|
23
|
-
"issn-l" =>
|
24
|
-
"doi" =>
|
25
|
-
"hdl" =>
|
26
|
-
"isrc" =>
|
27
|
-
"ismn" =>
|
28
|
-
"issue number" =>
|
29
|
-
"lccn" =>
|
30
|
-
"oclc" =>
|
31
|
-
"matrix number" =>
|
32
|
-
"music publisher" =>
|
33
|
-
"music plate" =>
|
34
|
-
"sici" =>
|
35
|
-
"upc" =>
|
36
|
-
"videorecording identifier" =>
|
37
|
-
"stock number" =>
|
20
|
+
{"local" => I18n.t('mods_display.identifier'),
|
21
|
+
"isbn" => I18n.t('mods_display.isbn'),
|
22
|
+
"issn" => I18n.t('mods_display.issn'),
|
23
|
+
"issn-l" => I18n.t('mods_display.issn'),
|
24
|
+
"doi" => I18n.t('mods_display.doi'),
|
25
|
+
"hdl" => I18n.t('mods_display.handle'),
|
26
|
+
"isrc" => I18n.t('mods_display.isrc'),
|
27
|
+
"ismn" => I18n.t('mods_display.ismn'),
|
28
|
+
"issue number" => I18n.t('mods_display.issue_number'),
|
29
|
+
"lccn" => I18n.t('mods_display.lccn'),
|
30
|
+
"oclc" => I18n.t('mods_display.oclc'),
|
31
|
+
"matrix number" => I18n.t('mods_display.matrix_number'),
|
32
|
+
"music publisher" => I18n.t('mods_display.music_publisher'),
|
33
|
+
"music plate" => I18n.t('mods_display.music_plate'),
|
34
|
+
"sici" => I18n.t('mods_display.sici'),
|
35
|
+
"upc" => I18n.t('mods_display.upc'),
|
36
|
+
"videorecording identifier" => I18n.t('mods_display.videorecording_identifier'),
|
37
|
+
"stock number" => I18n.t('mods_display.stock_number')}
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
@@ -33,7 +33,7 @@ class ModsDisplay::Imprint < ModsDisplay::Field
|
|
33
33
|
editionPlace = [edition, placePub].compact.join(" - ")
|
34
34
|
editionPlace = nil if editionPlace.strip.empty?
|
35
35
|
unless [editionPlace, parts].compact.join(", ").strip.empty?
|
36
|
-
return_fields << ModsDisplay::Values.new(:label => displayLabel(value) ||
|
36
|
+
return_fields << ModsDisplay::Values.new(:label => displayLabel(value) || I18n.t('mods_display.imprint'), :values => [[editionPlace, parts].compact.join(", ")])
|
37
37
|
end
|
38
38
|
if dates(value).length > 0
|
39
39
|
return_fields.concat(dates(value))
|
@@ -219,7 +219,7 @@ class ModsDisplay::Imprint < ModsDisplay::Field
|
|
219
219
|
display_form = element.children.find do |child|
|
220
220
|
child.name == "displayForm"
|
221
221
|
end
|
222
|
-
ModsDisplay::Values.new(:label => displayLabel(element) ||
|
222
|
+
ModsDisplay::Values.new(:label => displayLabel(element) || I18n.t('mods_display.imprint'), :values => [display_form.text]) if display_form
|
223
223
|
end
|
224
224
|
|
225
225
|
private
|
@@ -233,13 +233,13 @@ class ModsDisplay::Imprint < ModsDisplay::Field
|
|
233
233
|
end
|
234
234
|
|
235
235
|
def pub_info_labels
|
236
|
-
{:dateCreated =>
|
237
|
-
:dateCaptured =>
|
238
|
-
:dateValid =>
|
239
|
-
:dateModified =>
|
240
|
-
:copyrightDate =>
|
241
|
-
:issuance =>
|
242
|
-
:frequency =>
|
236
|
+
{:dateCreated => I18n.t('mods_display.date_created'),
|
237
|
+
:dateCaptured => I18n.t('mods_display.date_captured'),
|
238
|
+
:dateValid => I18n.t('mods_display.date_valid'),
|
239
|
+
:dateModified => I18n.t('mods_display.date_modified'),
|
240
|
+
:copyrightDate => I18n.t('mods_display.copyright_date'),
|
241
|
+
:issuance => I18n.t('mods_display.issuance'),
|
242
|
+
:frequency => I18n.t('mods_display.frequency')
|
243
243
|
}
|
244
244
|
end
|
245
245
|
|
@@ -4,7 +4,7 @@ class ModsDisplay::Language < ModsDisplay::Field
|
|
4
4
|
if value.respond_to?(:languageTerm)
|
5
5
|
value.languageTerm.map do |term|
|
6
6
|
if term.attributes["type"].respond_to?(:value) and term.attributes["type"].value == "code"
|
7
|
-
ModsDisplay::Values.new(:label => displayLabel(value) || displayLabel(term) ||
|
7
|
+
ModsDisplay::Values.new(:label => displayLabel(value) || displayLabel(term) || I18n.t('mods_display.language'), :values => [displayForm(value) || language_codes[term.text]].flatten)
|
8
8
|
end
|
9
9
|
end.flatten.compact
|
10
10
|
end
|
@@ -6,13 +6,13 @@ class ModsDisplay::Location < ModsDisplay::Field
|
|
6
6
|
location.children.each do |child|
|
7
7
|
if location_field_keys.include? child.name.to_sym
|
8
8
|
if child.name.to_sym == :url
|
9
|
-
loc_label = displayLabel(location) ||
|
10
|
-
value = "<a href='#{child.text}'>#{displayLabel(child) || child.text}</a>"
|
9
|
+
loc_label = displayLabel(location) || I18n.t('mods_display.location')
|
10
|
+
value = "<a href='#{child.text}'>#{(displayLabel(child) || child.text).gsub(/:$/,'')}</a>"
|
11
11
|
else
|
12
|
-
loc_label = location_label(child) || displayLabel(location) ||
|
12
|
+
loc_label = location_label(child) || displayLabel(location) || I18n.t('mods_display.location')
|
13
13
|
value = child.text
|
14
14
|
end
|
15
|
-
return_fields << ModsDisplay::Values.new(:label => loc_label || displayLabel(location) ||
|
15
|
+
return_fields << ModsDisplay::Values.new(:label => loc_label || displayLabel(location) || I18n.t('mods_display.location'),
|
16
16
|
:values => [value])
|
17
17
|
end
|
18
18
|
end
|
@@ -35,7 +35,7 @@ class ModsDisplay::Location < ModsDisplay::Field
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def location_labels
|
38
|
-
{"repository" =>
|
38
|
+
{"repository" => I18n.t('mods_display.repository')}
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
@@ -18,7 +18,7 @@ class ModsDisplay::Name < ModsDisplay::Field
|
|
18
18
|
return nil if fields.empty? or @config.ignore?
|
19
19
|
output = ""
|
20
20
|
fields.each do |field|
|
21
|
-
output << "<dt#{label_class}
|
21
|
+
output << "<dt#{label_class} #{sanitized_field_title(field.label)}>#{field.label}</dt>"
|
22
22
|
output << "<dd#{value_class}>"
|
23
23
|
output << field.values.map do |val|
|
24
24
|
if @config.link
|
@@ -38,9 +38,9 @@ class ModsDisplay::Name < ModsDisplay::Field
|
|
38
38
|
|
39
39
|
def name_label(element)
|
40
40
|
if !has_role?(element) || is_primary?(element) || has_author_or_creator_roles?(element)
|
41
|
-
|
41
|
+
I18n.t('mods_display.author_creator')
|
42
42
|
else
|
43
|
-
|
43
|
+
I18n.t('mods_display.contributor')
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -20,22 +20,21 @@ class ModsDisplay::Note < ModsDisplay::Field
|
|
20
20
|
|
21
21
|
def note_label(element)
|
22
22
|
if element.attributes["type"].respond_to?(:value)
|
23
|
-
return note_labels[element.attributes["type"].value] || element.attributes["type"].value.capitalize
|
23
|
+
return note_labels[element.attributes["type"].value] || "#{element.attributes["type"].value.capitalize}:"
|
24
24
|
end
|
25
|
-
|
25
|
+
I18n.t('mods_display.note')
|
26
26
|
end
|
27
27
|
|
28
28
|
def note_labels
|
29
|
-
{"statement of responsibility" =>
|
30
|
-
"date/sequential designation" =>
|
31
|
-
"publications" =>
|
32
|
-
"references" =>
|
33
|
-
"bibliography" =>
|
34
|
-
"preferred citation" =>
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"
|
38
|
-
"citation/reference" => "Citation/Reference"
|
29
|
+
{"statement of responsibility" => I18n.t('mods_display.statement_of_responsibility'),
|
30
|
+
"date/sequential designation" => I18n.t('mods_display.date_sequential_designation'),
|
31
|
+
"publications" => I18n.t('mods_display.publications'),
|
32
|
+
"references" => I18n.t('mods_display.references'),
|
33
|
+
"bibliography" => I18n.t('mods_display.bibliography'),
|
34
|
+
"preferred citation" => I18n.t('mods_display.preferred_citation'),
|
35
|
+
"biographical/historical" => I18n.t('mods_display.biographical_historical'),
|
36
|
+
"creation/production credits" => I18n.t('mods_display.creation_production_credits'),
|
37
|
+
"citation/reference" => I18n.t('mods_display.citation_reference')
|
39
38
|
}
|
40
39
|
end
|
41
40
|
|
@@ -74,11 +74,11 @@ class ModsDisplay::RelatedItem < ModsDisplay::Field
|
|
74
74
|
else
|
75
75
|
case
|
76
76
|
when related_item_is_a_location?(item)
|
77
|
-
return
|
77
|
+
return I18n.t('mods_display.location')
|
78
78
|
when related_item_is_a_reference?(item)
|
79
|
-
return
|
79
|
+
return I18n.t('mods_display.referenced_by')
|
80
80
|
end
|
81
|
-
|
81
|
+
I18n.t('mods_display.related_item')
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
@@ -4,7 +4,7 @@ class ModsDisplay::Subject < ModsDisplay::Field
|
|
4
4
|
return_fields = []
|
5
5
|
@values.each do |value|
|
6
6
|
return_values = []
|
7
|
-
label = displayLabel(value) ||
|
7
|
+
label = displayLabel(value) || I18n.t('mods_display.subject')
|
8
8
|
return_text = []
|
9
9
|
selected_subjects(value).each do |child|
|
10
10
|
if self.respond_to?(:"process_#{child.name}")
|
@@ -32,7 +32,7 @@ class ModsDisplay::Subject < ModsDisplay::Field
|
|
32
32
|
return nil if fields.empty? or @config.ignore?
|
33
33
|
output = ""
|
34
34
|
fields.each do |field|
|
35
|
-
output << "<dt#{label_class}
|
35
|
+
output << "<dt#{label_class} #{sanitized_field_title(field.label)}>#{field.label}</dt>"
|
36
36
|
output << "<dd#{value_class}>"
|
37
37
|
subs = []
|
38
38
|
field.values.each do |subjects|
|
@@ -46,14 +46,14 @@ class ModsDisplay::Title < ModsDisplay::Field
|
|
46
46
|
title_labels.has_key?(element.attributes["type"].value))
|
47
47
|
return title_labels[element.attributes["type"].value]
|
48
48
|
end
|
49
|
-
|
49
|
+
I18n.t('mods_display.title')
|
50
50
|
end
|
51
51
|
|
52
52
|
def title_labels
|
53
|
-
{"abbreviated" =>
|
54
|
-
"translated" =>
|
55
|
-
"alternative" =>
|
56
|
-
"uniform" =>
|
53
|
+
{"abbreviated" => I18n.t('mods_display.abbreviated_title'),
|
54
|
+
"translated" => I18n.t('mods_display.translated_title'),
|
55
|
+
"alternative" => I18n.t('mods_display.alternative_title'),
|
56
|
+
"uniform" => I18n.t('mods_display.uniform_title')}
|
57
57
|
end
|
58
58
|
|
59
59
|
end
|
data/lib/mods_display/version.rb
CHANGED
data/mods_display.gemspec
CHANGED
@@ -14,7 +14,7 @@ describe ModsDisplay::Abstract do
|
|
14
14
|
it "should get a default 'Abstract' label" do
|
15
15
|
fields = mods_display_abstract(@link).fields
|
16
16
|
fields.length.should == 1
|
17
|
-
fields.first.label.should == "Abstract"
|
17
|
+
fields.first.label.should == "Abstract:"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -23,7 +23,7 @@ describe ModsDisplay::AccessCondition do
|
|
23
23
|
it "should normalize types and assign proper labels" do
|
24
24
|
fields = mods_display_access_condition(@restrict_condition).fields
|
25
25
|
fields.length.should == 1
|
26
|
-
fields.first.label.should == "Restriction on access"
|
26
|
+
fields.first.label.should == "Restriction on access:"
|
27
27
|
fields.first.values.each_with_index do |value, index|
|
28
28
|
value.should match /^Restrict Access Note#{index+1}/
|
29
29
|
end
|
@@ -11,10 +11,10 @@ describe ModsDisplay::Contents do
|
|
11
11
|
end
|
12
12
|
describe "label" do
|
13
13
|
it "should have a default label" do
|
14
|
-
mods_display_audience(@audience).label.should == "Target audience"
|
14
|
+
mods_display_audience(@audience).label.should == "Target audience:"
|
15
15
|
end
|
16
16
|
it "should use the displayLabel attribute when one is available" do
|
17
|
-
mods_display_audience(@display_label).label.should == "Special Label"
|
17
|
+
mods_display_audience(@display_label).label.should == "Special Label:"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -12,10 +12,10 @@ describe ModsDisplay::Collection do
|
|
12
12
|
end
|
13
13
|
describe "label" do
|
14
14
|
it "should default to Collection" do
|
15
|
-
mods_display_collection(@collection).label.should == "Collection"
|
15
|
+
mods_display_collection(@collection).label.should == "Collection:"
|
16
16
|
end
|
17
17
|
it "should get the displayLabel if available" do
|
18
|
-
mods_display_collection(@display_label).label.should == "Special Collection"
|
18
|
+
mods_display_collection(@display_label).label.should == "Special Collection:"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
describe "fields" do
|
@@ -11,10 +11,10 @@ describe ModsDisplay::Contents do
|
|
11
11
|
end
|
12
12
|
describe "label" do
|
13
13
|
it "should have a default label" do
|
14
|
-
mods_display_contents(@contents).label.should == "Table of contents"
|
14
|
+
mods_display_contents(@contents).label.should == "Table of contents:"
|
15
15
|
end
|
16
16
|
it "should use the displayLabel attribute when one is available" do
|
17
|
-
mods_display_contents(@display_label).label.should == "Special Label"
|
17
|
+
mods_display_contents(@display_label).label.should == "Special Label:"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -13,16 +13,16 @@ describe ModsDisplay::Description do
|
|
13
13
|
end
|
14
14
|
describe "labels" do
|
15
15
|
it "should use the displayLabel if one is provided" do
|
16
|
-
mods_display_description(@display_label).fields.first.label.should == "SpecialLabel"
|
16
|
+
mods_display_description(@display_label).fields.first.label.should == "SpecialLabel:"
|
17
17
|
end
|
18
18
|
it "should get the default label for a child element" do
|
19
|
-
mods_display_description(@form).fields.first.label.should == "Note"
|
19
|
+
mods_display_description(@form).fields.first.label.should == "Note:"
|
20
20
|
end
|
21
21
|
it "should get multiple lables for mixed content" do
|
22
|
-
mods_display_description(@mixed).fields.map{|v| v.label }.should == ["Note", "Digital origin"]
|
22
|
+
mods_display_description(@mixed).fields.map{|v| v.label }.should == ["Note:", "Digital origin:"]
|
23
23
|
end
|
24
24
|
it "should get the display label from child elements" do
|
25
|
-
mods_display_description(@child_display_label).fields.map{|f| f.label }.should == ["Note Label"]
|
25
|
+
mods_display_description(@child_display_label).fields.map{|f| f.label }.should == ["Note Label:"]
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
data/spec/fields/genre_spec.rb
CHANGED
@@ -14,12 +14,12 @@ describe ModsDisplay::Abstract do
|
|
14
14
|
it "should return a default 'Genre' label" do
|
15
15
|
fields = mods_display_genre(@genre).fields
|
16
16
|
fields.length.should == 1
|
17
|
-
fields.first.label.should == "Genre"
|
17
|
+
fields.first.label.should == "Genre:"
|
18
18
|
end
|
19
19
|
it "should use a display label when one is available" do
|
20
20
|
fields = mods_display_genre(@display_label).fields
|
21
21
|
fields.length.should == 1
|
22
|
-
fields.first.label.should == "Special label"
|
22
|
+
fields.first.label.should == "Special label:"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
describe "fields" do
|
@@ -14,16 +14,16 @@ describe ModsDisplay::Note do
|
|
14
14
|
end
|
15
15
|
describe "label" do
|
16
16
|
it "should have a default label" do
|
17
|
-
mods_display_id(@id).fields.first.label.should == "Identifier"
|
17
|
+
mods_display_id(@id).fields.first.label.should == "Identifier:"
|
18
18
|
end
|
19
19
|
it "should use the displayLabel attribute when one is available" do
|
20
|
-
mods_display_id(@display_label).fields.first.label.should == "Special Label"
|
20
|
+
mods_display_id(@display_label).fields.first.label.should == "Special Label:"
|
21
21
|
end
|
22
22
|
it "should use get a label from a list of translations" do
|
23
|
-
mods_display_id(@issue_label).fields.first.label.should == "Issue number"
|
23
|
+
mods_display_id(@issue_label).fields.first.label.should == "Issue number:"
|
24
24
|
end
|
25
25
|
it "should use use the raw type attribute if one is present" do
|
26
|
-
mods_display_id(@type_label).fields.first.label.should == "Some other Type"
|
26
|
+
mods_display_id(@type_label).fields.first.label.should == "Some other Type:"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -32,15 +32,15 @@ describe ModsDisplay::Note do
|
|
32
32
|
fields = mods_display_id(@complex_label).fields
|
33
33
|
fields.length.should == 3
|
34
34
|
|
35
|
-
fields.first.label.should == "Identifier"
|
35
|
+
fields.first.label.should == "Identifier:"
|
36
36
|
fields.first.values.length.should == 2
|
37
37
|
fields.first.values.should == ["12345", "54321"]
|
38
38
|
|
39
|
-
fields[1].label.should == "Issue number"
|
39
|
+
fields[1].label.should == "Issue number:"
|
40
40
|
fields[1].values.length.should == 1
|
41
41
|
fields[1].values.should == ["12345"]
|
42
42
|
|
43
|
-
fields.last.label.should == "Identifier"
|
43
|
+
fields.last.label.should == "Identifier:"
|
44
44
|
fields.last.values.length.should == 1
|
45
45
|
fields.last.values.should == ["98765"]
|
46
46
|
end
|
data/spec/fields/imprint_spec.rb
CHANGED
@@ -39,18 +39,18 @@ describe ModsDisplay::Imprint do
|
|
39
39
|
|
40
40
|
describe "labels" do
|
41
41
|
it "should get the Imprint label by default" do
|
42
|
-
mods_display_imprint(@imprint).fields.first.label.should == "Imprint"
|
42
|
+
mods_display_imprint(@imprint).fields.first.label.should == "Imprint:"
|
43
43
|
end
|
44
44
|
it "should get the label from non-imprint origin info fields" do
|
45
45
|
fields = mods_display_imprint(@edition_and_date).fields
|
46
|
-
fields.first.label.should == "Date valid"
|
47
|
-
fields.last.label.should == "Issuance"
|
46
|
+
fields.first.label.should == "Date valid:"
|
47
|
+
fields.last.label.should == "Issuance:"
|
48
48
|
end
|
49
49
|
it "should get multiple labels when we have mixed content" do
|
50
|
-
mods_display_imprint(@mixed).fields.map{|val| val.label }.should == ["Imprint", "Date captured", "Issuance"]
|
50
|
+
mods_display_imprint(@mixed).fields.map{|val| val.label }.should == ["Imprint:", "Date captured:", "Issuance:"]
|
51
51
|
end
|
52
52
|
it "should use the displayLabel when available" do
|
53
|
-
mods_display_imprint(@display_label).fields.map{|val| val.label }.should == ["TheLabel", "IssuanceLabel"]
|
53
|
+
mods_display_imprint(@display_label).fields.map{|val| val.label }.should == ["TheLabel:", "IssuanceLabel:"]
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -149,38 +149,38 @@ describe ModsDisplay::Imprint do
|
|
149
149
|
fields = mods_display_imprint(@encoded_dates).fields
|
150
150
|
fields.length.should == 4
|
151
151
|
fields.find do |field|
|
152
|
-
field.label == "Imprint"
|
152
|
+
field.label == "Imprint:"
|
153
153
|
end.values.should == ["2013"]
|
154
154
|
end
|
155
155
|
it "should handle month+year dates properly" do
|
156
156
|
fields = mods_display_imprint(@encoded_dates).fields
|
157
157
|
fields.length.should == 4
|
158
158
|
fields.find do |field|
|
159
|
-
field.label == "Date captured"
|
159
|
+
field.label == "Date captured:"
|
160
160
|
end.values.should == ["July 2013"]
|
161
161
|
end
|
162
162
|
it "should handle full dates properly" do
|
163
163
|
fields = mods_display_imprint(@encoded_dates).fields
|
164
164
|
fields.length.should == 4
|
165
165
|
fields.find do |field|
|
166
|
-
field.label == "Date created"
|
166
|
+
field.label == "Date created:"
|
167
167
|
end.values.should == ["July 10, 2013"]
|
168
168
|
end
|
169
169
|
it "should not try to handle dates we can't parse" do
|
170
170
|
fields = mods_display_imprint(@encoded_dates).fields
|
171
171
|
fields.length.should == 4
|
172
172
|
fields.find do |field|
|
173
|
-
field.label == "Date modified"
|
173
|
+
field.label == "Date modified:"
|
174
174
|
end.values.should == ["Jul. 22, 2013"]
|
175
175
|
end
|
176
176
|
it "should accept date configurations" do
|
177
177
|
fields = mods_display_format_date_imprint(@encoded_dates).fields
|
178
178
|
fields.length.should == 4
|
179
179
|
fields.find do |field|
|
180
|
-
field.label == "Date created"
|
180
|
+
field.label == "Date created:"
|
181
181
|
end.values.should == ["(2013) July, 10"]
|
182
182
|
fields.find do |field|
|
183
|
-
field.label == "Date captured"
|
183
|
+
field.label == "Date captured:"
|
184
184
|
end.values.should == ["July (2013)"]
|
185
185
|
end
|
186
186
|
end
|
@@ -18,7 +18,7 @@ describe ModsDisplay::Language do
|
|
18
18
|
values = mods_display_language(@display_label).fields
|
19
19
|
values.length.should == 1
|
20
20
|
values.first.should be_a ModsDisplay::Values
|
21
|
-
values.first.label.should == "Lang"
|
21
|
+
values.first.label.should == "Lang:"
|
22
22
|
values.first.values.should == ["English"]
|
23
23
|
end
|
24
24
|
it "should not return any non type='code' languageTerms from the XML" do
|
@@ -13,16 +13,16 @@ describe ModsDisplay::Note do
|
|
13
13
|
end
|
14
14
|
describe "label" do
|
15
15
|
it "should have a default label" do
|
16
|
-
mods_display_location(@location).fields.first.label.should == "Location"
|
16
|
+
mods_display_location(@location).fields.first.label.should == "Location:"
|
17
17
|
end
|
18
18
|
it "should use the displayLabel attribute when one is available" do
|
19
|
-
mods_display_location(@display_label).fields.first.label.should == "Special Label"
|
19
|
+
mods_display_location(@display_label).fields.first.label.should == "Special Label:"
|
20
20
|
end
|
21
21
|
it "should handle the URL labels correctly" do
|
22
|
-
mods_display_location(@urls).fields.map{|f| f.label}.should == ["Location", "PURL"]
|
22
|
+
mods_display_location(@urls).fields.map{|f| f.label}.should == ["Location:", "PURL:"]
|
23
23
|
end
|
24
24
|
it "should use get a label from a list of translations" do
|
25
|
-
mods_display_location(@repository_label).fields.first.label.should == "Repository"
|
25
|
+
mods_display_location(@repository_label).fields.first.label.should == "Repository:"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
describe "fields" do
|
@@ -30,13 +30,13 @@ describe ModsDisplay::Note do
|
|
30
30
|
it "should link and use the displayLabel as text" do
|
31
31
|
fields = mods_display_location(@urls).fields
|
32
32
|
fields.length.should == 2
|
33
|
-
field = fields.find{|f| f.label == "Location"}
|
33
|
+
field = fields.find{|f| f.label == "Location:"}
|
34
34
|
field.values.should == ["<a href='http://library.stanford.edu'>Stanford University Library</a>"]
|
35
35
|
end
|
36
36
|
it "should link the URL itself in the absence of a displayLabel on the url element" do
|
37
37
|
fields = mods_display_location(@urls).fields
|
38
38
|
fields.length.should == 2
|
39
|
-
field = fields.find{|f| f.label == "PURL"}
|
39
|
+
field = fields.find{|f| f.label == "PURL:"}
|
40
40
|
field.values.should == ["<a href='http://purl.stanford.edu'>http://purl.stanford.edu</a>"]
|
41
41
|
end
|
42
42
|
end
|
data/spec/fields/name_spec.rb
CHANGED
@@ -32,13 +32,13 @@ describe ModsDisplay::Language do
|
|
32
32
|
end
|
33
33
|
describe "label" do
|
34
34
|
it "should default Author/Creator when no role is available" do
|
35
|
-
mods_display_name(@name).fields.first.label.should == "Author/Creator"
|
35
|
+
mods_display_name(@name).fields.first.label.should == "Author/Creator:"
|
36
36
|
end
|
37
37
|
it "should label 'Author/Creator' for primary authors" do
|
38
|
-
mods_display_name(@primary_name).fields.first.label.should == "Author/Creator"
|
38
|
+
mods_display_name(@primary_name).fields.first.label.should == "Author/Creator:"
|
39
39
|
end
|
40
40
|
it "should apply contributor labeling to all non blank/author/creator roles" do
|
41
|
-
mods_display_name(@contributor).fields.first.label.should == "Contributor"
|
41
|
+
mods_display_name(@contributor).fields.first.label.should == "Contributor:"
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -70,7 +70,7 @@ describe ModsDisplay::Language do
|
|
70
70
|
it "should collapse adjacent matching labels" do
|
71
71
|
fields = mods_display_name(@collapse_label).fields
|
72
72
|
fields.length.should == 1
|
73
|
-
fields.first.label.should == "Author/Creator"
|
73
|
+
fields.first.label.should == "Author/Creator:"
|
74
74
|
fields.first.values.each do |val|
|
75
75
|
["John Doe", "Jane Doe"].should include val.to_s
|
76
76
|
end
|
@@ -79,16 +79,16 @@ describe ModsDisplay::Language do
|
|
79
79
|
fields = mods_display_name(@complex_labels).fields
|
80
80
|
|
81
81
|
fields.length.should == 3
|
82
|
-
fields.first.label.should == "Author/Creator"
|
82
|
+
fields.first.label.should == "Author/Creator:"
|
83
83
|
fields.first.values.length.should == 1
|
84
84
|
fields.first.values.first.to_s.should == "John Doe"
|
85
85
|
|
86
|
-
fields[1].label.should == "Contributor"
|
86
|
+
fields[1].label.should == "Contributor:"
|
87
87
|
fields[1].values.length.should == 1
|
88
88
|
fields[1].values.first.name.should == "Jane Doe"
|
89
89
|
fields[1].values.first.roles.should == ["lithographer"]
|
90
90
|
|
91
|
-
fields.last.label.should == "Author/Creator"
|
91
|
+
fields.last.label.should == "Author/Creator:"
|
92
92
|
fields.last.values.length.should == 2
|
93
93
|
fields.last.values.each do |val|
|
94
94
|
["Jane Dough", "John Dough"].should include val.to_s
|
data/spec/fields/note_spec.rb
CHANGED
@@ -15,16 +15,16 @@ describe ModsDisplay::Note do
|
|
15
15
|
end
|
16
16
|
describe "label" do
|
17
17
|
it "should have a default label" do
|
18
|
-
mods_display_note(@note).fields.first.label.should == "Note"
|
18
|
+
mods_display_note(@note).fields.first.label.should == "Note:"
|
19
19
|
end
|
20
20
|
it "should use the displayLabel attribute when one is available" do
|
21
|
-
mods_display_note(@display_label).fields.first.label.should == "Special Label"
|
21
|
+
mods_display_note(@display_label).fields.first.label.should == "Special Label:"
|
22
22
|
end
|
23
23
|
it "should use get a label from a list of translations" do
|
24
|
-
mods_display_note(@sor_label).fields.first.label.should == "Statement of responsibility"
|
24
|
+
mods_display_note(@sor_label).fields.first.label.should == "Statement of responsibility:"
|
25
25
|
end
|
26
26
|
it "should use use the capitalized type attribute if one is present" do
|
27
|
-
mods_display_note(@type_label).fields.first.label.should == "Some other type"
|
27
|
+
mods_display_note(@type_label).fields.first.label.should == "Some other type:"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -37,7 +37,7 @@ describe ModsDisplay::Note do
|
|
37
37
|
it "should handle complex grouping" do
|
38
38
|
fields = mods_display_note(@complex_label).fields
|
39
39
|
fields.length.should == 3
|
40
|
-
fields.first.label.should == "Note"
|
40
|
+
fields.first.label.should == "Note:"
|
41
41
|
fields.first.values.length == 2
|
42
42
|
fields.first.values.should == ["Note Field", "2nd Note Field"]
|
43
43
|
|
@@ -45,7 +45,7 @@ describe ModsDisplay::Note do
|
|
45
45
|
fields[1].values.length == 1
|
46
46
|
fields[1].values.should == ["SoR"]
|
47
47
|
|
48
|
-
fields.last.label.should == "Note"
|
48
|
+
fields.last.label.should == "Note:"
|
49
49
|
fields.last.values.length == 1
|
50
50
|
fields.last.values.should == ["Another Note"]
|
51
51
|
end
|
@@ -17,16 +17,16 @@ describe ModsDisplay::RelatedItem do
|
|
17
17
|
end
|
18
18
|
describe "label" do
|
19
19
|
it "should default to Related Item" do
|
20
|
-
mods_display_item(@item).fields.first.label.should == "Related item"
|
20
|
+
mods_display_item(@item).fields.first.label.should == "Related item:"
|
21
21
|
end
|
22
22
|
it "should get the location label" do
|
23
|
-
mods_display_item(@location).fields.first.label.should == "Location"
|
23
|
+
mods_display_item(@location).fields.first.label.should == "Location:"
|
24
24
|
end
|
25
25
|
it "should get the reference label" do
|
26
|
-
mods_display_item(@reference).fields.first.label.should == "Referenced by"
|
26
|
+
mods_display_item(@reference).fields.first.label.should == "Referenced by:"
|
27
27
|
end
|
28
28
|
it "should get the displayLabel if available" do
|
29
|
-
mods_display_item(@display_label).fields.first.label.should == "Special Item"
|
29
|
+
mods_display_item(@display_label).fields.first.label.should == "Special Item:"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
describe "fields" do
|
@@ -54,7 +54,7 @@ describe ModsDisplay::RelatedItem do
|
|
54
54
|
it "should collapse labels down into the same record" do
|
55
55
|
fields = mods_display_item(@multi_items).fields
|
56
56
|
fields.length.should == 1
|
57
|
-
fields.first.label.should == "Related item"
|
57
|
+
fields.first.label.should == "Related item:"
|
58
58
|
fields.first.values.length.should == 2
|
59
59
|
fields.first.values.first.should =~ /<a href=.*>Library<\/a>/ or
|
60
60
|
fields.first.values.last.should =~ /<a href=.*>SDR<\/a>/
|
@@ -13,12 +13,12 @@ describe ModsDisplay::ResourceType do
|
|
13
13
|
it "should default to a label of 'Type of resource'" do
|
14
14
|
fields = mods_display_resource_type(@type).fields
|
15
15
|
fields.length.should == 1
|
16
|
-
fields.first.label.should == "Type of resource"
|
16
|
+
fields.first.label.should == "Type of resource:"
|
17
17
|
end
|
18
18
|
it "should use the displayLabel attribute when present" do
|
19
19
|
fields = mods_display_resource_type(@display_label).fields
|
20
20
|
fields.length.should == 1
|
21
|
-
fields.first.label.should == "Special label"
|
21
|
+
fields.first.label.should == "Special label:"
|
22
22
|
end
|
23
23
|
it "should capitalize the first letter of the values" do
|
24
24
|
fields = mods_display_resource_type(@downcase).fields
|
@@ -11,7 +11,7 @@ describe ModsDisplay::SubTitle do
|
|
11
11
|
it "omit the main title and only return sub titles" do
|
12
12
|
fields = mods_display_sub_title(@title).fields
|
13
13
|
fields.length.should == 1
|
14
|
-
fields.first.label.should == "Title"
|
14
|
+
fields.first.label.should == "Title:"
|
15
15
|
fields.first.values.should == ["Sub Title"]
|
16
16
|
|
17
17
|
end
|
data/spec/fields/subject_spec.rb
CHANGED
@@ -46,11 +46,11 @@ describe ModsDisplay::Subject do
|
|
46
46
|
it "should handle display labels properly" do
|
47
47
|
fields = mods_display_subject(@display_label).fields
|
48
48
|
fields.length.should == 3
|
49
|
-
fields.first.label.should == "Subject"
|
49
|
+
fields.first.label.should == "Subject:"
|
50
50
|
fields.first.values.should == [["A Subject", "Another Subject"], ["B Subject", "Another B Subject"]]
|
51
|
-
fields[1].label.should == "Subject Heading"
|
51
|
+
fields[1].label.should == "Subject Heading:"
|
52
52
|
fields[1].values.should == [["Jazz", "Japan", "History and criticism"]]
|
53
|
-
fields.last.label.should == "Subject"
|
53
|
+
fields.last.label.should == "Subject:"
|
54
54
|
fields.last.values.should == [["Bay Area", "Stanford"]]
|
55
55
|
end
|
56
56
|
it "should handle blank subjects properly" do
|
data/spec/fields/title_spec.rb
CHANGED
@@ -16,21 +16,21 @@ describe ModsDisplay::Title do
|
|
16
16
|
end
|
17
17
|
describe "labels" do
|
18
18
|
it "should return a default label of Title if nothing else is available" do
|
19
|
-
mods_display_title(@title).fields.first.label.should == "Title"
|
19
|
+
mods_display_title(@title).fields.first.label.should == "Title:"
|
20
20
|
end
|
21
21
|
it "should return an appropriate label from the type attribute" do
|
22
|
-
mods_display_title(@alt_title).fields.first.label.should == "Alternative title"
|
22
|
+
mods_display_title(@alt_title).fields.first.label.should == "Alternative title:"
|
23
23
|
end
|
24
24
|
it "should return the label held in the displayLabel attribute of the titleInfo element when available" do
|
25
|
-
mods_display_title(@display_label).fields.first.label.should == "MyTitle"
|
25
|
+
mods_display_title(@display_label).fields.first.label.should == "MyTitle:"
|
26
26
|
end
|
27
27
|
it "should collapse adjacent identical labels" do
|
28
28
|
fields = mods_display_title(@multi_label).fields
|
29
29
|
fields.length.should == 4
|
30
|
-
fields[0].label.should == "Title"
|
31
|
-
fields[1].label.should == "Alternative title"
|
32
|
-
fields[2].label.should == "Uniform title"
|
33
|
-
fields[3].label.should == "Alternative title"
|
30
|
+
fields[0].label.should == "Title:"
|
31
|
+
fields[1].label.should == "Alternative title:"
|
32
|
+
fields[2].label.should == "Uniform title:"
|
33
|
+
fields[3].label.should == "Alternative title:"
|
34
34
|
fields[3].values.should == ["Another Alt Title", "Yet Another Alt Title"]
|
35
35
|
end
|
36
36
|
end
|
@@ -39,7 +39,7 @@ describe ModsDisplay::Title do
|
|
39
39
|
values = mods_display_title(@display_label).fields
|
40
40
|
values.length.should == 1
|
41
41
|
values.first.should be_a ModsDisplay::Values
|
42
|
-
values.first.label.should == "MyTitle"
|
42
|
+
values.first.label.should == "MyTitle:"
|
43
43
|
values.first.values.should == ["Title"]
|
44
44
|
end
|
45
45
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
require "spec_helper"
|
2
3
|
|
3
|
-
def html_from_mods(xml)
|
4
|
+
def html_from_mods(xml, locale=nil)
|
4
5
|
model = TestModel.new
|
5
6
|
model.modsxml = xml
|
7
|
+
I18n.locale = locale if locale
|
6
8
|
TestController.new.render_mods_display(model)
|
7
9
|
end
|
8
10
|
|
@@ -10,8 +12,24 @@ describe "HTML Output" do
|
|
10
12
|
before(:all) do
|
11
13
|
@multiple_titles = html_from_mods("<mods><titleInfo><title>Main Title</title></titleInfo><titleInfo type='alternative'><title>Alternate Title</title></titleInfo></mods>")
|
12
14
|
@abstract = html_from_mods("<mods><abstract>Hey. I'm an abstract.</abstract></mods>")
|
15
|
+
mods = "<mods><titleInfo><title>Main Title</title></titleInfo><abstract>Hey. I'm an abstract.</abstract></mods>"
|
16
|
+
@mods = html_from_mods(mods)
|
17
|
+
@fr_mods = html_from_mods(mods, :fr)
|
18
|
+
end
|
19
|
+
after(:all) do
|
20
|
+
I18n.locale = :en
|
21
|
+
end
|
22
|
+
describe "i18n" do
|
23
|
+
it "should get the default english translations" do
|
24
|
+
expect(@mods.to_html).to match(/<dt title='Title'>Title:<\/dt>/)
|
25
|
+
end
|
26
|
+
it "should internationalize the labels when translations are available" do
|
27
|
+
expect(@fr_mods.to_html).to match(/<dt title='Résumé'>Résumé :<\/dt>/)
|
28
|
+
end
|
29
|
+
it "should get fallback to the default english translations if a translation is missing" do
|
30
|
+
expect(@fr_mods.to_html).to match(/<dt title='Title'>Title:<\/dt>/)
|
31
|
+
end
|
13
32
|
end
|
14
|
-
|
15
33
|
describe "titles" do
|
16
34
|
it "should include both titles it regular display" do
|
17
35
|
@multiple_titles.to_html.should include("<dd>Main Title</dd>")
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require "mods_display"
|
2
2
|
require "stanford-mods"
|
3
3
|
|
4
|
+
# Load i18n test file.
|
5
|
+
# We don't have any reliable translations yet so this
|
6
|
+
# just make sure that we're handling i18n properly.
|
7
|
+
I18n.load_path += Dir["#{File.expand_path('../..', __FILE__)}/spec/test_fr.yml"]
|
8
|
+
I18n.backend.load_translations
|
9
|
+
|
4
10
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
5
11
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
6
12
|
# Require this file using `require "spec_helper"` to ensure that it is only
|
data/spec/test_fr.yml
ADDED
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.3.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: 2013-12-
|
11
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stanford-mods
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: i18n
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,6 +79,7 @@ files:
|
|
65
79
|
- LICENSE.txt
|
66
80
|
- README.md
|
67
81
|
- Rakefile
|
82
|
+
- config/locales/en.yml
|
68
83
|
- lib/mods_display.rb
|
69
84
|
- lib/mods_display/configuration.rb
|
70
85
|
- lib/mods_display/configuration/access_condition.rb
|
@@ -137,6 +152,7 @@ files:
|
|
137
152
|
- spec/integration/html_spec.rb
|
138
153
|
- spec/integration/installation_spec.rb
|
139
154
|
- spec/spec_helper.rb
|
155
|
+
- spec/test_fr.yml
|
140
156
|
homepage: https://github.com/sul-dlss/mods_display
|
141
157
|
licenses: []
|
142
158
|
metadata: {}
|
@@ -194,3 +210,4 @@ test_files:
|
|
194
210
|
- spec/integration/html_spec.rb
|
195
211
|
- spec/integration/installation_spec.rb
|
196
212
|
- spec/spec_helper.rb
|
213
|
+
- spec/test_fr.yml
|