mods_display 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mods_display.rb +7 -1
- data/lib/mods_display/configuration.rb +7 -3
- data/lib/mods_display/configuration/access_condition.rb +17 -0
- data/lib/mods_display/configuration/format.rb +5 -0
- data/lib/mods_display/configuration/genre.rb +5 -0
- data/lib/mods_display/configuration/imprint.rb +8 -0
- data/lib/mods_display/controller_extension.rb +1 -1
- data/lib/mods_display/country_codes.rb +385 -0
- data/lib/mods_display/fields/access_condition.rb +73 -0
- data/lib/mods_display/fields/description.rb +1 -3
- data/lib/mods_display/fields/format.rb +23 -16
- data/lib/mods_display/fields/genre.rb +7 -1
- data/lib/mods_display/fields/identifier.rb +1 -0
- data/lib/mods_display/fields/imprint.rb +55 -6
- data/lib/mods_display/fields/location.rb +25 -3
- data/lib/mods_display/fields/name.rb +82 -13
- data/lib/mods_display/fields/related_item.rb +73 -14
- data/lib/mods_display/fields/resource_type.rb +7 -0
- data/lib/mods_display/html.rb +15 -9
- data/lib/mods_display/model_extension.rb +1 -0
- data/lib/mods_display/relator_codes.rb +268 -0
- data/lib/mods_display/version.rb +1 -1
- data/spec/configuration/access_condition_spec.rb +10 -0
- data/spec/fields/access_condition_spec.rb +91 -0
- data/spec/fields/description_spec.rb +9 -9
- data/spec/fields/format_spec.rb +10 -14
- data/spec/fields/genre_spec.rb +9 -1
- data/spec/fields/imprint_spec.rb +63 -2
- data/spec/fields/location_spec.rb +21 -2
- data/spec/fields/name_spec.rb +30 -0
- data/spec/fields/related_item_spec.rb +13 -0
- data/spec/fields/resource_type_spec.rb +6 -0
- data/spec/fixtures/imprint_fixtures.rb +36 -2
- data/spec/integration/configuration_spec.rb +14 -2
- metadata +15 -7
- data/lib/mods_display/fields/related_location.rb +0 -16
- data/spec/fields/related_location_spec.rb +0 -35
@@ -6,32 +6,32 @@ end
|
|
6
6
|
|
7
7
|
describe ModsDisplay::Description do
|
8
8
|
before(:all) do
|
9
|
-
@form = Stanford::Mods::Record.new.from_str("<mods><physicalDescription><
|
10
|
-
@display_label = Stanford::Mods::Record.new.from_str("<mods><physicalDescription displayLabel='SpecialLabel'><
|
11
|
-
@child_display_label = Stanford::Mods::Record.new.from_str("<mods><physicalDescription><
|
12
|
-
@mixed = Stanford::Mods::Record.new.from_str("<mods><physicalDescription><
|
9
|
+
@form = Stanford::Mods::Record.new.from_str("<mods><physicalDescription><note>Description Note</note></physicalDescription></mods>", false).physical_description
|
10
|
+
@display_label = Stanford::Mods::Record.new.from_str("<mods><physicalDescription displayLabel='SpecialLabel'><note>Description Note</note></physicalDescription></mods>", false).physical_description
|
11
|
+
@child_display_label = Stanford::Mods::Record.new.from_str("<mods><physicalDescription><note displayLabel='Note Label'>Description Note</note></physicalDescription></mods>", false).physical_description
|
12
|
+
@mixed = Stanford::Mods::Record.new.from_str("<mods><physicalDescription><note>Description Note</note><digitalOrigin>Digital Origin Note</digitalOrigin></physicalDescription></mods>", false).physical_description
|
13
13
|
end
|
14
14
|
describe "labels" do
|
15
15
|
it "should use the displayLabel if one is provided" do
|
16
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 == "
|
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 == ["
|
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 == ["
|
25
|
+
mods_display_description(@child_display_label).fields.map{|f| f.label }.should == ["Note Label"]
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe "fields" do
|
30
30
|
it "should get the value from a field in physicalDescription" do
|
31
|
-
mods_display_description(@form).fields.first.values.should == ["
|
31
|
+
mods_display_description(@form).fields.first.values.should == ["Description Note"]
|
32
32
|
end
|
33
33
|
it "should get multiple values for mixed content" do
|
34
|
-
mods_display_description(@mixed).fields.map{|v| v.values }.should == [["
|
34
|
+
mods_display_description(@mixed).fields.map{|v| v.values }.should == [["Description Note"], ["Digital Origin Note"]]
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/spec/fields/format_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
|
3
2
|
def mods_display_format(mods)
|
4
3
|
ModsDisplay::Format.new(mods, ModsDisplay::Configuration::Base.new, mock("controller"))
|
5
4
|
end
|
@@ -7,23 +6,12 @@ end
|
|
7
6
|
describe ModsDisplay::Format do
|
8
7
|
before(:all) do
|
9
8
|
@format = Stanford::Mods::Record.new.from_str("<mods><typeOfResource>Format</typeOfResource></mods>", false).typeOfResource
|
9
|
+
@duplicate_forms = Stanford::Mods::Record.new.from_str("<mods><physicalDescription><form>Map</form><form>Map</form></physicalDescription></mods>", false)
|
10
10
|
@display_label = Stanford::Mods::Record.new.from_str("<mods><typeOfResource displayLabel='SpecialFormat'>Mixed Materials</typeOfResource></mods>", false).typeOfResource
|
11
11
|
@space_format = Stanford::Mods::Record.new.from_str("<mods><typeOfResource>Mixed Materials</typeOfResource></mods>", false).typeOfResource
|
12
12
|
@slash_format = Stanford::Mods::Record.new.from_str("<mods><typeOfResource>Manuscript/Archive</typeOfResource></mods>", false).typeOfResource
|
13
13
|
end
|
14
|
-
|
15
|
-
describe "labels" do
|
16
|
-
it "should return the format label" do
|
17
|
-
mods_display_format(@format).to_html.should match(/<dt title='Format'>Format:<\/dt>/)
|
18
|
-
end
|
19
|
-
it "should return the displayLabel when available" do
|
20
|
-
mods_display_format(@display_label).to_html.should match(/<dt title='SpecialFormat'>SpecialFormat:<\/dt>/)
|
21
|
-
end
|
22
|
-
end
|
23
14
|
describe "format_class" do
|
24
|
-
it "should wrap the format in a span w/ the format class in it" do
|
25
|
-
mods_display_format(@format).to_html.should match(/<span class='format'>Format<\/span>/)
|
26
|
-
end
|
27
15
|
it "should remove any spaces" do
|
28
16
|
ModsDisplay::Format.send(:format_class, "Mixed Materials").should == "mixed_materials"
|
29
17
|
end
|
@@ -31,5 +19,13 @@ describe ModsDisplay::Format do
|
|
31
19
|
ModsDisplay::Format.send(:format_class, "Manuscript/Archive").should == "manuscript_archive"
|
32
20
|
end
|
33
21
|
end
|
34
|
-
|
22
|
+
describe "fields" do
|
23
|
+
describe "form" do
|
24
|
+
it "should remove duplicate values" do
|
25
|
+
fields = mods_display_format(@duplicate_forms).fields
|
26
|
+
fields.length.should == 1
|
27
|
+
fields.first.values.should == ["Map"]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
35
31
|
end
|
data/spec/fields/genre_spec.rb
CHANGED
@@ -6,7 +6,8 @@ end
|
|
6
6
|
|
7
7
|
describe ModsDisplay::Abstract do
|
8
8
|
before(:all) do
|
9
|
-
@genre = Stanford::Mods::Record.new.from_str("<mods><genre>Map Data</
|
9
|
+
@genre = Stanford::Mods::Record.new.from_str("<mods><genre>Map Data</genre></mods>", false).genre
|
10
|
+
@downcase = Stanford::Mods::Record.new.from_str("<mods><genre>map data</genre></mods>", false).genre
|
10
11
|
@display_label = Stanford::Mods::Record.new.from_str("<mods><genre displayLabel='Special label'>Catographic</genre></mods>", false).genre
|
11
12
|
end
|
12
13
|
describe "labels" do
|
@@ -21,4 +22,11 @@ describe ModsDisplay::Abstract do
|
|
21
22
|
fields.first.label.should == "Special label"
|
22
23
|
end
|
23
24
|
end
|
25
|
+
describe "fields" do
|
26
|
+
it "should capitalize the first letter in a genre" do
|
27
|
+
fields = mods_display_genre(@downcase).fields
|
28
|
+
fields.length.should == 1
|
29
|
+
fields.first.values.should == ["Map data"]
|
30
|
+
end
|
31
|
+
end
|
24
32
|
end
|
data/spec/fields/imprint_spec.rb
CHANGED
@@ -4,7 +4,10 @@ require "fixtures/imprint_fixtures"
|
|
4
4
|
include ImprintFixtures
|
5
5
|
|
6
6
|
def mods_display_imprint(mods_record)
|
7
|
-
ModsDisplay::Imprint.new(mods_record, ModsDisplay::Configuration::
|
7
|
+
ModsDisplay::Imprint.new(mods_record, ModsDisplay::Configuration::Imprint.new, mock("controller"))
|
8
|
+
end
|
9
|
+
def mods_display_format_date_imprint(mods_record)
|
10
|
+
ModsDisplay::Imprint.new(mods_record, ModsDisplay::Configuration::Imprint.new{full_date_format "(%Y) %B, %d"; short_date_format "%B (%Y)"}, mock("controller"))
|
8
11
|
end
|
9
12
|
|
10
13
|
describe ModsDisplay::Imprint do
|
@@ -29,6 +32,8 @@ describe ModsDisplay::Imprint do
|
|
29
32
|
@qualified_imprint_date = Stanford::Mods::Record.new.from_str(qualified_imprint_date, false).origin_info
|
30
33
|
@imprint_date_range = Stanford::Mods::Record.new.from_str(imprint_date_range, false).origin_info
|
31
34
|
@encoded_place = Stanford::Mods::Record.new.from_str(encoded_place, false).origin_info
|
35
|
+
@encoded_dates = Stanford::Mods::Record.new.from_str(encoded_dates, false).origin_info
|
36
|
+
@bad_dates = Stanford::Mods::Record.new.from_str(bad_dates, false).origin_info
|
32
37
|
end
|
33
38
|
|
34
39
|
describe "labels" do
|
@@ -137,12 +142,68 @@ describe ModsDisplay::Imprint do
|
|
137
142
|
fields.first.values.should == ["[1820]"]
|
138
143
|
end
|
139
144
|
end
|
145
|
+
describe "encoded dates" do
|
146
|
+
describe "W3CDTF" do
|
147
|
+
it "should handle single year dates properly" do
|
148
|
+
fields = mods_display_imprint(@encoded_dates).fields
|
149
|
+
fields.length.should == 4
|
150
|
+
fields.find do |field|
|
151
|
+
field.label == "Imprint"
|
152
|
+
end.values.should == ["2013"]
|
153
|
+
end
|
154
|
+
it "should handle month+year dates properly" do
|
155
|
+
fields = mods_display_imprint(@encoded_dates).fields
|
156
|
+
fields.length.should == 4
|
157
|
+
fields.find do |field|
|
158
|
+
field.label == "Date captured"
|
159
|
+
end.values.should == ["July 2013"]
|
160
|
+
end
|
161
|
+
it "should handle full dates properly" do
|
162
|
+
fields = mods_display_imprint(@encoded_dates).fields
|
163
|
+
fields.length.should == 4
|
164
|
+
fields.find do |field|
|
165
|
+
field.label == "Date created"
|
166
|
+
end.values.should == ["July 10, 2013"]
|
167
|
+
end
|
168
|
+
it "should not try to handle dates we can't parse" do
|
169
|
+
fields = mods_display_imprint(@encoded_dates).fields
|
170
|
+
fields.length.should == 4
|
171
|
+
fields.find do |field|
|
172
|
+
field.label == "Date modified"
|
173
|
+
end.values.should == ["Jul. 22, 2013"]
|
174
|
+
end
|
175
|
+
it "should accept date configurations" do
|
176
|
+
fields = mods_display_format_date_imprint(@encoded_dates).fields
|
177
|
+
fields.length.should == 4
|
178
|
+
fields.find do |field|
|
179
|
+
field.label == "Date created"
|
180
|
+
end.values.should == ["(2013) July, 10"]
|
181
|
+
fields.find do |field|
|
182
|
+
field.label == "Date captured"
|
183
|
+
end.values.should == ["July (2013)"]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
describe "bad dates" do
|
188
|
+
it "should ignore date values" do
|
189
|
+
fields = mods_display_imprint(@bad_dates).fields
|
190
|
+
fields.length.should == 2
|
191
|
+
fields.each do |field|
|
192
|
+
field.values.join.should_not include "9999"
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
140
196
|
end
|
141
197
|
describe "place processing" do
|
142
198
|
it "should exclude encoded places" do
|
143
199
|
fields = mods_display_imprint(@encoded_place).fields
|
144
200
|
fields.length.should == 1
|
145
|
-
fields.first.values.should == ["[Amsterdam]", "[United States]"]
|
201
|
+
fields.first.values.should == ["[Amsterdam]", "[United States]", "Netherlands"]
|
202
|
+
end
|
203
|
+
it "should translate encoded place if there isn't a text (or non-typed) value available" do
|
204
|
+
fields = mods_display_imprint(@encoded_place).fields
|
205
|
+
fields.length.should == 1
|
206
|
+
fields.first.values.should include "Netherlands"
|
146
207
|
end
|
147
208
|
end
|
148
209
|
describe "to_html" do
|
@@ -7,8 +7,9 @@ end
|
|
7
7
|
describe ModsDisplay::Note do
|
8
8
|
before(:all) do
|
9
9
|
@location = Stanford::Mods::Record.new.from_str("<mods><location><physicalLocation>The Location</physicalLocation></location></mods>", false).location
|
10
|
+
@urls = Stanford::Mods::Record.new.from_str("<mods><location><url displayLabel='Stanford University Library'>http://library.stanford.edu</url></location><location displayLabel='PURL'><url>http://purl.stanford.edu</url></location></mods>", false).location
|
10
11
|
@display_label = Stanford::Mods::Record.new.from_str("<mods><location displayLabel='Special Label'><shelfLocation>On Shelf A</shelfLocation></location></mods>", false).location
|
11
|
-
@repository_label = Stanford::Mods::Record.new.from_str("<mods><location type='repository'
|
12
|
+
@repository_label = Stanford::Mods::Record.new.from_str("<mods><location><physicalLocation type='repository'>Location Field</physicalLocation></location></mods>", false).location
|
12
13
|
end
|
13
14
|
describe "label" do
|
14
15
|
it "should have a default label" do
|
@@ -17,9 +18,27 @@ describe ModsDisplay::Note do
|
|
17
18
|
it "should use the displayLabel attribute when one is available" do
|
18
19
|
mods_display_location(@display_label).fields.first.label.should == "Special Label"
|
19
20
|
end
|
21
|
+
it "should handle the URL labels correctly" do
|
22
|
+
mods_display_location(@urls).fields.map{|f| f.label}.should == ["Location", "PURL"]
|
23
|
+
end
|
20
24
|
it "should use get a label from a list of translations" do
|
21
25
|
mods_display_location(@repository_label).fields.first.label.should == "Repository"
|
22
26
|
end
|
23
27
|
end
|
24
|
-
|
28
|
+
describe "fields" do
|
29
|
+
describe "URLs" do
|
30
|
+
it "should link and use the displayLabel as text" do
|
31
|
+
fields = mods_display_location(@urls).fields
|
32
|
+
fields.length.should == 2
|
33
|
+
field = fields.find{|f| f.label == "Location"}
|
34
|
+
field.values.should == ["<a href='http://library.stanford.edu'>Stanford University Library</a>"]
|
35
|
+
end
|
36
|
+
it "should link the URL itself in the absence of a displayLabel on the url element" do
|
37
|
+
fields = mods_display_location(@urls).fields
|
38
|
+
fields.length.should == 2
|
39
|
+
field = fields.find{|f| f.label == "PURL"}
|
40
|
+
field.values.should == ["<a href='http://purl.stanford.edu'>http://purl.stanford.edu</a>"]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
25
44
|
end
|
data/spec/fields/name_spec.rb
CHANGED
@@ -19,6 +19,10 @@ describe ModsDisplay::Language do
|
|
19
19
|
@blank_name = Stanford::Mods::Record.new.from_str("<mods><name><namePart/><role><roleTerm></roleTerm></role></name></mods>", false).plain_name
|
20
20
|
@conf_name = Stanford::Mods::Record.new.from_str("<mods><name type='conference'><namePart>John Doe</namePart></name></mods>", false).plain_name
|
21
21
|
@contributor = Stanford::Mods::Record.new.from_str("<mods><name><namePart>John Doe</namePart><role><roleTerm>lithographer</roleTerm></role></name></mods>", false).plain_name
|
22
|
+
@encoded_role = Stanford::Mods::Record.new.from_str("<mods><name><namePart>John Doe</namePart><role><roleTerm type='code' authority='marcrelator'>ltg</roleTerm></role></name></mods>", false).plain_name
|
23
|
+
@mixed_role = Stanford::Mods::Record.new.from_str("<mods><name><role><roleTerm>publisher</roleTerm></role><namePart>John Doe</namePart><role><roleTerm type='text' authority='marcrelator'>engraver</roleTerm></role></name></mods>", false).plain_name
|
24
|
+
@numeral_toa = Stanford::Mods::Record.new.from_str("<mods><name><namePart>Unqualfieid</namePart><namePart type='termsOfAddress'>XVII, ToA</namePart><namePart type='date'>date1-date2</namePart><namePart type='given'>Given Name</namePart><namePart type='family'>Family Name</namePart></name></mods>", false).plain_name
|
25
|
+
@simple_toa = Stanford::Mods::Record.new.from_str("<mods><name><namePart>Unqualfieid</namePart><namePart type='termsOfAddress'>Ier, empereur</namePart><namePart type='date'>date1-date2</namePart><namePart type='given'>Given Name</namePart><namePart type='family'>Family Name</namePart></name></mods>", false).plain_name
|
22
26
|
@display_form = Stanford::Mods::Record.new.from_str("<mods><name><namePart>John Doe</namePart><displayForm>Mr. John Doe</displayForm></name></mods>", false).plain_name
|
23
27
|
@collapse_label = Stanford::Mods::Record.new.from_str("<mods><name><namePart>John Doe</namePart></name><name><namePart>Jane Doe</namePart></name></mods>", false).plain_name
|
24
28
|
@complex_labels = Stanford::Mods::Record.new.from_str("<mods><name><namePart>John Doe</namePart></name><name><namePart>Jane Doe</namePart></name><name type='conference'><namePart>John Dough</namePart></name><name><namePart>Jane Dough</namePart></name></mods>", false).plain_name
|
@@ -51,9 +55,35 @@ describe ModsDisplay::Language do
|
|
51
55
|
fields.first.values.first.should be_a(ModsDisplay::Name::Person)
|
52
56
|
fields.first.values.first.role.should == "Depicted"
|
53
57
|
end
|
58
|
+
it "should decode encoded roleTerms when no text (or non-typed) roleTerm is available" do
|
59
|
+
fields = mods_display_name(@encoded_role).fields
|
60
|
+
fields.length.should == 1
|
61
|
+
fields.first.values.length.should == 1
|
62
|
+
fields.first.values.first.to_s.should == "John Doe (Lithographer)"
|
63
|
+
end
|
64
|
+
it "should get the type='text' role before an untyped role" do
|
65
|
+
fields = mods_display_name(@mixed_role).fields
|
66
|
+
fields.length.should == 1
|
67
|
+
fields.first.values.length.should == 1
|
68
|
+
fields.first.values.first.role.should == "engraver"
|
69
|
+
end
|
54
70
|
it "should not add blank names" do
|
55
71
|
mods_display_name(@blank_name).fields.should == []
|
56
72
|
end
|
73
|
+
it "should not delimit given name and termsOfAddress (that begin w/ roman numerals) with a comma" do
|
74
|
+
fields = mods_display_name(@numeral_toa).fields
|
75
|
+
fields.length.should == 1
|
76
|
+
fields.first.values.length.should == 1
|
77
|
+
fields.first.values.first.to_s.should_not match /Given Name, XVII/
|
78
|
+
fields.first.values.first.to_s.should match /Given Name XVII/
|
79
|
+
end
|
80
|
+
it "should delimit given name and termsOfAddress (that DO NOT begin w/ roman numerals) with a comma" do
|
81
|
+
fields = mods_display_name(@simple_toa).fields
|
82
|
+
fields.length.should == 1
|
83
|
+
fields.first.values.length.should == 1
|
84
|
+
fields.first.values.first.to_s.should match /Given Name, Ier, empereur/
|
85
|
+
fields.first.values.first.to_s.should_not match /Given Name Ier, empereur/
|
86
|
+
end
|
57
87
|
it "should collapse adjacent matching labels" do
|
58
88
|
fields = mods_display_name(@collapse_label).fields
|
59
89
|
fields.length.should == 1
|
@@ -10,6 +10,8 @@ describe ModsDisplay::RelatedItem do
|
|
10
10
|
@linked_item = Stanford::Mods::Record.new.from_str("<mods><relatedItem><titleInfo>A Related Item</titleInfo><location><url>http://library.stanford.edu/</url></location></relatedItem></mods>", false).related_item
|
11
11
|
@collection = Stanford::Mods::Record.new.from_str("<mods><relatedItem><titleInfo>This is a Collection</titleInfo><typeOfResource collection='yes' /></relatedItem></mods>", false).related_item
|
12
12
|
@display_label = Stanford::Mods::Record.new.from_str("<mods><relatedItem displayLabel='Special Item'><titleInfo>A Related Item</titleInfo></relatedItem></mods>", false).related_item
|
13
|
+
@location = Stanford::Mods::Record.new.from_str("<mods><relatedItem><location>The Location</location></relatedItem></mods>", false).related_item
|
14
|
+
@reference = Stanford::Mods::Record.new.from_str("<mods><relatedItem type='isReferencedBy'><titleInfo>The title</titleInfo><note>124</note><originInfo><dateOther>DATE</dateOther></originInfo></relatedItem></mods>", false).related_item
|
13
15
|
@blank_item = Stanford::Mods::Record.new.from_str("<mods><relatedItem><titleInfo><title></title></titleInfo><location><url></url></location></relatedItem></mods>", false).related_item
|
14
16
|
@multi_items = Stanford::Mods::Record.new.from_str("<mods><relatedItem><titleInfo><title>Library</title></titleInfo><location><url>http://library.stanford.edu</url></location></relatedItem><relatedItem><titleInfo><title>SDR</title></titleInfo><location><url>http://purl.stanford.edu</url></location></relatedItem></mods>", false).related_item
|
15
17
|
end
|
@@ -17,6 +19,12 @@ describe ModsDisplay::RelatedItem do
|
|
17
19
|
it "should default to Related Item" do
|
18
20
|
mods_display_item(@item).fields.first.label.should == "Related item"
|
19
21
|
end
|
22
|
+
it "should get the location label" do
|
23
|
+
mods_display_item(@location).fields.first.label.should == "Location"
|
24
|
+
end
|
25
|
+
it "should get the reference label" do
|
26
|
+
mods_display_item(@reference).fields.first.label.should == "Referenced by"
|
27
|
+
end
|
20
28
|
it "should get the displayLabel if available" do
|
21
29
|
mods_display_item(@display_label).fields.first.label.should == "Special Item"
|
22
30
|
end
|
@@ -38,6 +46,11 @@ describe ModsDisplay::RelatedItem do
|
|
38
46
|
it "should not return empty links when there is no title or link" do
|
39
47
|
mods_display_item(@blank_item).fields.should == []
|
40
48
|
end
|
49
|
+
it "should concat the isReferencedBy related item title with other metadata" do
|
50
|
+
fields = mods_display_item(@reference).fields
|
51
|
+
fields.length.should == 1
|
52
|
+
fields.first.values.should == ["The title DATE 124"]
|
53
|
+
end
|
41
54
|
it "should collapse labels down into the same record" do
|
42
55
|
fields = mods_display_item(@multi_items).fields
|
43
56
|
fields.length.should == 1
|
@@ -7,6 +7,7 @@ end
|
|
7
7
|
describe ModsDisplay::ResourceType do
|
8
8
|
before(:all) do
|
9
9
|
@type = Stanford::Mods::Record.new.from_str("<mods><typeOfResource>Resource Type</typeOfResource></mods>", false).typeOfResource
|
10
|
+
@downcase = Stanford::Mods::Record.new.from_str("<mods><typeOfResource>resource type</typeOfResource></mods>", false).typeOfResource
|
10
11
|
@display_label = Stanford::Mods::Record.new.from_str("<mods><typeOfResource displayLabel='Special label'>Resource Type</typeOfResource></mods>", false).typeOfResource
|
11
12
|
end
|
12
13
|
it "should default to a label of 'Type of resource'" do
|
@@ -19,4 +20,9 @@ describe ModsDisplay::ResourceType do
|
|
19
20
|
fields.length.should == 1
|
20
21
|
fields.first.label.should == "Special label"
|
21
22
|
end
|
23
|
+
it "should capitalize the first letter of the values" do
|
24
|
+
fields = mods_display_resource_type(@downcase).fields
|
25
|
+
fields.length.should == 1
|
26
|
+
fields.first.values.should == ["Resource type"]
|
27
|
+
end
|
22
28
|
end
|
@@ -204,10 +204,10 @@ module ImprintFixtures
|
|
204
204
|
<mods>
|
205
205
|
<originInfo>
|
206
206
|
<place>
|
207
|
-
<placeTerm type="code">ne</placeTerm>
|
207
|
+
<placeTerm type="code" authority="marccountry">ne</placeTerm>
|
208
208
|
</place>
|
209
209
|
<place>
|
210
|
-
<placeTerm type="text">[Amsterdam]</placeTerm>
|
210
|
+
<placeTerm type="text" authority="marccountry">[Amsterdam]</placeTerm>
|
211
211
|
</place>
|
212
212
|
</originInfo>
|
213
213
|
<originInfo>
|
@@ -216,6 +216,40 @@ module ImprintFixtures
|
|
216
216
|
<placeTerm type="text">[United States]</placeTerm>
|
217
217
|
</place>
|
218
218
|
</originInfo>
|
219
|
+
<originInfo>
|
220
|
+
<place>
|
221
|
+
<placeTerm type="code" authority="marccountry">ne</placeTerm>
|
222
|
+
</place>
|
223
|
+
</originInfo>
|
224
|
+
</mods>
|
225
|
+
MODS
|
226
|
+
end
|
227
|
+
def encoded_dates
|
228
|
+
<<-MODS
|
229
|
+
<mods>
|
230
|
+
<originInfo>
|
231
|
+
<dateOther encoding="w3cDtF">2013</dateOther>
|
232
|
+
<dateCreated encoding="W3CdTf">2013-07-10</dateCreated>
|
233
|
+
<dateCaptured encoding="W3CDTF">2013-07</dateCaptured>
|
234
|
+
<dateModified encoding="w3cdtf">Jul. 22, 2013</dateModified>
|
235
|
+
</originInfo>
|
236
|
+
</mods>
|
237
|
+
MODS
|
238
|
+
end
|
239
|
+
def bad_dates
|
240
|
+
<<-MODS
|
241
|
+
<mods>
|
242
|
+
<originInfo>
|
243
|
+
<place>
|
244
|
+
<placeTerm>United States</placeTerm>
|
245
|
+
</place>
|
246
|
+
<dateIssued>
|
247
|
+
9999
|
248
|
+
</dateIssued>
|
249
|
+
<dateModified>
|
250
|
+
9999
|
251
|
+
</dateModified>
|
252
|
+
</originInfo>
|
219
253
|
</mods>
|
220
254
|
MODS
|
221
255
|
end
|
@@ -1,5 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
+
class TestNoConfigController
|
4
|
+
include ModsDisplay::ControllerExtension
|
5
|
+
end
|
6
|
+
|
3
7
|
class TestConfigController
|
4
8
|
include ModsDisplay::ControllerExtension
|
5
9
|
|
@@ -24,8 +28,9 @@ describe "Configuration" do
|
|
24
28
|
xml = "<mods><titleInfo><title>The Title of this Item</title></titleInfo><note type='contact'>jdoe@example.com</note></mods>"
|
25
29
|
model = TestModel.new
|
26
30
|
model.modsxml = xml
|
27
|
-
|
28
|
-
@
|
31
|
+
@no_config_controller = TestNoConfigController.new
|
32
|
+
@config_controller = TestConfigController.new
|
33
|
+
@html = @config_controller.render_mods_display(model)
|
29
34
|
end
|
30
35
|
it "should apply the label class" do
|
31
36
|
@html.should match(/<dt class='label-class' title=/)
|
@@ -39,4 +44,11 @@ describe "Configuration" do
|
|
39
44
|
it "should ignore fields if requested" do
|
40
45
|
@html.scan(/jdoe@example\.com/).length.should == 0
|
41
46
|
end
|
47
|
+
it "should get overriden configurations" do
|
48
|
+
@no_config_controller.mods_display_config.contact.ignore?.should be_false
|
49
|
+
@config_controller.mods_display_config.contact.ignore?.should be_true
|
50
|
+
end
|
51
|
+
it "should get default configurations when no controller configuration is supplied" do
|
52
|
+
@no_config_controller.mods_display_config.note.delimiter.should == "<br/>"
|
53
|
+
end
|
42
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mods_display
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: stanford-mods
|
@@ -74,13 +74,19 @@ files:
|
|
74
74
|
- Rakefile
|
75
75
|
- lib/mods_display.rb
|
76
76
|
- lib/mods_display/configuration.rb
|
77
|
+
- lib/mods_display/configuration/access_condition.rb
|
77
78
|
- lib/mods_display/configuration/base.rb
|
79
|
+
- lib/mods_display/configuration/format.rb
|
80
|
+
- lib/mods_display/configuration/genre.rb
|
81
|
+
- lib/mods_display/configuration/imprint.rb
|
78
82
|
- lib/mods_display/configuration/name.rb
|
79
83
|
- lib/mods_display/configuration/note.rb
|
80
84
|
- lib/mods_display/configuration/related_item.rb
|
81
85
|
- lib/mods_display/configuration/subject.rb
|
82
86
|
- lib/mods_display/controller_extension.rb
|
87
|
+
- lib/mods_display/country_codes.rb
|
83
88
|
- lib/mods_display/fields/abstract.rb
|
89
|
+
- lib/mods_display/fields/access_condition.rb
|
84
90
|
- lib/mods_display/fields/audience.rb
|
85
91
|
- lib/mods_display/fields/cartographics.rb
|
86
92
|
- lib/mods_display/fields/collection.rb
|
@@ -97,7 +103,6 @@ files:
|
|
97
103
|
- lib/mods_display/fields/name.rb
|
98
104
|
- lib/mods_display/fields/note.rb
|
99
105
|
- lib/mods_display/fields/related_item.rb
|
100
|
-
- lib/mods_display/fields/related_location.rb
|
101
106
|
- lib/mods_display/fields/resource_type.rb
|
102
107
|
- lib/mods_display/fields/sub_title.rb
|
103
108
|
- lib/mods_display/fields/subject.rb
|
@@ -105,10 +110,13 @@ files:
|
|
105
110
|
- lib/mods_display/fields/values.rb
|
106
111
|
- lib/mods_display/html.rb
|
107
112
|
- lib/mods_display/model_extension.rb
|
113
|
+
- lib/mods_display/relator_codes.rb
|
108
114
|
- lib/mods_display/version.rb
|
109
115
|
- mods_display.gemspec
|
116
|
+
- spec/configuration/access_condition_spec.rb
|
110
117
|
- spec/configuration/base_spec.rb
|
111
118
|
- spec/fields/abstract_spec.rb
|
119
|
+
- spec/fields/access_condition_spec.rb
|
112
120
|
- spec/fields/audience_spec.rb
|
113
121
|
- spec/fields/cartographics_spec.rb
|
114
122
|
- spec/fields/collection_spec.rb
|
@@ -124,7 +132,6 @@ files:
|
|
124
132
|
- spec/fields/name_spec.rb
|
125
133
|
- spec/fields/note_spec.rb
|
126
134
|
- spec/fields/related_item_spec.rb
|
127
|
-
- spec/fields/related_location_spec.rb
|
128
135
|
- spec/fields/resource_type_spec.rb
|
129
136
|
- spec/fields/sub_title_spec.rb
|
130
137
|
- spec/fields/subject_spec.rb
|
@@ -151,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
158
|
version: '0'
|
152
159
|
segments:
|
153
160
|
- 0
|
154
|
-
hash:
|
161
|
+
hash: 841363986478259673
|
155
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
163
|
none: false
|
157
164
|
requirements:
|
@@ -160,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
167
|
version: '0'
|
161
168
|
segments:
|
162
169
|
- 0
|
163
|
-
hash:
|
170
|
+
hash: 841363986478259673
|
164
171
|
requirements: []
|
165
172
|
rubyforge_project:
|
166
173
|
rubygems_version: 1.8.25
|
@@ -170,8 +177,10 @@ summary: The MODS Display gem allows implementers to configure a customized disp
|
|
170
177
|
of MODS metadata. This display implements the specifications defined at Stanford
|
171
178
|
for how to display MODS.
|
172
179
|
test_files:
|
180
|
+
- spec/configuration/access_condition_spec.rb
|
173
181
|
- spec/configuration/base_spec.rb
|
174
182
|
- spec/fields/abstract_spec.rb
|
183
|
+
- spec/fields/access_condition_spec.rb
|
175
184
|
- spec/fields/audience_spec.rb
|
176
185
|
- spec/fields/cartographics_spec.rb
|
177
186
|
- spec/fields/collection_spec.rb
|
@@ -187,7 +196,6 @@ test_files:
|
|
187
196
|
- spec/fields/name_spec.rb
|
188
197
|
- spec/fields/note_spec.rb
|
189
198
|
- spec/fields/related_item_spec.rb
|
190
|
-
- spec/fields/related_location_spec.rb
|
191
199
|
- spec/fields/resource_type_spec.rb
|
192
200
|
- spec/fields/sub_title_spec.rb
|
193
201
|
- spec/fields/subject_spec.rb
|