mods_display 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ class ModsDisplay::Imprint < ModsDisplay::Field
|
|
13
13
|
edition = value.edition.map do |e|
|
14
14
|
e.text unless e.text.strip.empty?
|
15
15
|
end.compact.join(" ").strip
|
16
|
-
place = value.
|
16
|
+
place = place_terms(value).map do |p|
|
17
17
|
p.text unless p.text.strip.empty?
|
18
18
|
end.compact.join(" : ").strip unless value.place.text.strip.empty?
|
19
19
|
publisher = value.publisher.map do |p|
|
@@ -150,14 +150,22 @@ class ModsDisplay::Imprint < ModsDisplay::Field
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
def normalize_date(date)
|
153
|
-
date.strip.gsub(/^\
|
153
|
+
date.strip.gsub(/^\[*ca\.\s*|c|\[|\]|\?/, "")
|
154
154
|
end
|
155
155
|
def other_pub_info(element)
|
156
156
|
element.children.select do |child|
|
157
157
|
pub_info_parts.include?(child.name.to_sym)
|
158
158
|
end
|
159
159
|
end
|
160
|
-
|
160
|
+
def place_terms(element)
|
161
|
+
return [] unless element.respond_to?(:place) and
|
162
|
+
element.place.respond_to?(:placeTerm)
|
163
|
+
element.place.placeTerm.select do |term|
|
164
|
+
!term.attributes["type"] or
|
165
|
+
!term.attributes["type"].respond_to?(:value) or
|
166
|
+
term.attributes["type"].value != "code"
|
167
|
+
end.compact
|
168
|
+
end
|
161
169
|
def imprint_display_form(element)
|
162
170
|
display_form = element.children.find do |child|
|
163
171
|
child.name == "displayForm"
|
data/lib/mods_display/version.rb
CHANGED
data/spec/fields/imprint_spec.rb
CHANGED
@@ -20,6 +20,7 @@ describe ModsDisplay::Imprint do
|
|
20
20
|
@open_date_range = Stanford::Mods::Record.new.from_str(open_date_range, false).origin_info
|
21
21
|
@dup_qualified_date = Stanford::Mods::Record.new.from_str(dup_qualified_date, false).origin_info
|
22
22
|
@dup_unencoded_date = Stanford::Mods::Record.new.from_str(dup_unencoded_date, false).origin_info
|
23
|
+
@dup_copyright_date = Stanford::Mods::Record.new.from_str(dup_copyright_date, false).origin_info
|
23
24
|
@dup_date = Stanford::Mods::Record.new.from_str(dup_date, false).origin_info
|
24
25
|
@approximate_date = Stanford::Mods::Record.new.from_str(approximate_date, false).origin_info
|
25
26
|
@questionable_date = Stanford::Mods::Record.new.from_str(questionable_date, false).origin_info
|
@@ -27,6 +28,7 @@ describe ModsDisplay::Imprint do
|
|
27
28
|
@three_imprint_dates = Stanford::Mods::Record.new.from_str(three_imprint_dates, false).origin_info
|
28
29
|
@qualified_imprint_date = Stanford::Mods::Record.new.from_str(qualified_imprint_date, false).origin_info
|
29
30
|
@imprint_date_range = Stanford::Mods::Record.new.from_str(imprint_date_range, false).origin_info
|
31
|
+
@encoded_place = Stanford::Mods::Record.new.from_str(encoded_place, false).origin_info
|
30
32
|
end
|
31
33
|
|
32
34
|
describe "labels" do
|
@@ -107,6 +109,11 @@ describe ModsDisplay::Imprint do
|
|
107
109
|
fields.length.should == 1
|
108
110
|
fields.first.values.should == ["[ca. 1820]"]
|
109
111
|
end
|
112
|
+
it "should handle copyright dates correctly" do
|
113
|
+
fields = mods_display_imprint(@dup_copyright_date).fields
|
114
|
+
fields.length.should == 1
|
115
|
+
fields.first.values.should == ["c1820"]
|
116
|
+
end
|
110
117
|
it "should only return one when no attributes are present" do
|
111
118
|
fields = mods_display_imprint(@dup_date).fields
|
112
119
|
fields.length.should == 1
|
@@ -131,6 +138,13 @@ describe ModsDisplay::Imprint do
|
|
131
138
|
end
|
132
139
|
end
|
133
140
|
end
|
141
|
+
describe "place processing" do
|
142
|
+
it "should exclude encoded places" do
|
143
|
+
fields = mods_display_imprint(@encoded_place).fields
|
144
|
+
fields.length.should == 1
|
145
|
+
fields.first.values.should == ["[Amsterdam]", "[United States]"]
|
146
|
+
end
|
147
|
+
end
|
134
148
|
describe "to_html" do
|
135
149
|
it "should return the display form if one is available" do
|
136
150
|
html = mods_display_imprint(@display_form).to_html
|
@@ -4,7 +4,7 @@ module ImprintFixtures
|
|
4
4
|
<mods>
|
5
5
|
<originInfo>
|
6
6
|
<edition>An edition</edition>
|
7
|
-
<place>A Place</place>
|
7
|
+
<place><placeTerm>A Place</placeTerm></place>
|
8
8
|
<publisher>A Publisher</publisher>
|
9
9
|
<dateIssued>An Issue Date</dateIssued>
|
10
10
|
<dateOther>Another Date</dateOther>
|
@@ -16,7 +16,7 @@ module ImprintFixtures
|
|
16
16
|
<<-MODS
|
17
17
|
<mods>
|
18
18
|
<originInfo>
|
19
|
-
<place>A Place</place>
|
19
|
+
<place><placeTerm>A Place</placeTerm></place>
|
20
20
|
<publisher>A Publisher</publisher>
|
21
21
|
<dateCreated>A Create Date</dateCreated>
|
22
22
|
<dateIssued>An Issue Date</dateIssued>
|
@@ -42,7 +42,7 @@ module ImprintFixtures
|
|
42
42
|
<<-MODS
|
43
43
|
<mods>
|
44
44
|
<originInfo>
|
45
|
-
<place>A Place</place>
|
45
|
+
<place><placeTerm>A Place</placeTerm></place>
|
46
46
|
<publisher>A Publisher</publisher>
|
47
47
|
<issuance>The Issuance</issuance>
|
48
48
|
<dateCaptured>The Capture Date</dateCaptured>
|
@@ -54,12 +54,12 @@ module ImprintFixtures
|
|
54
54
|
<<-MODS
|
55
55
|
<mods>
|
56
56
|
<originInfo>
|
57
|
-
<place>A Place</place>
|
57
|
+
<place><placeTerm>A Place</placeTerm></place>
|
58
58
|
<publisher>A Publisher</publisher>
|
59
59
|
<displayForm>The Display Form</displayForm>
|
60
60
|
</originInfo>
|
61
61
|
<originInfo displayLabel="TheLabel">
|
62
|
-
<place>A Place</place>
|
62
|
+
<place><placeTerm>A Place</placeTerm></place>
|
63
63
|
<publisher>A Publisher</publisher>
|
64
64
|
<displayForm>The Display Form</displayForm>
|
65
65
|
</originInfo>
|
@@ -71,11 +71,11 @@ module ImprintFixtures
|
|
71
71
|
<mods>
|
72
72
|
<originInfo displayLabel="TheLabel">
|
73
73
|
<edition>The edition</edition>
|
74
|
-
<place>A Place</place>
|
74
|
+
<place><placeTerm>A Place</placeTerm></place>
|
75
75
|
<publisher>A Publisher</publisher>
|
76
76
|
</originInfo>
|
77
77
|
<originInfo displayLabel="IssuanceLabel">
|
78
|
-
<place>A Place</place>
|
78
|
+
<place><placeTerm>A Place</placeTerm></place>
|
79
79
|
<publisher>A Publisher</publisher>
|
80
80
|
<issuance>The Edition</issuance>
|
81
81
|
</originInfo>
|
@@ -121,6 +121,16 @@ module ImprintFixtures
|
|
121
121
|
</mods>
|
122
122
|
MODS
|
123
123
|
end
|
124
|
+
def dup_copyright_date
|
125
|
+
<<-MODS
|
126
|
+
<mods>
|
127
|
+
<originInfo>
|
128
|
+
<dateCreated encoding="marc">1820</dateCreated>
|
129
|
+
<dateCreated>c1820</dateCreated>
|
130
|
+
</originInfo>
|
131
|
+
</mods>
|
132
|
+
MODS
|
133
|
+
end
|
124
134
|
def dup_date
|
125
135
|
<<-MODS
|
126
136
|
<mods>
|
@@ -189,4 +199,24 @@ module ImprintFixtures
|
|
189
199
|
</mods>
|
190
200
|
MODS
|
191
201
|
end
|
202
|
+
def encoded_place
|
203
|
+
<<-MODS
|
204
|
+
<mods>
|
205
|
+
<originInfo>
|
206
|
+
<place>
|
207
|
+
<placeTerm type="code">ne</placeTerm>
|
208
|
+
</place>
|
209
|
+
<place>
|
210
|
+
<placeTerm type="text">[Amsterdam]</placeTerm>
|
211
|
+
</place>
|
212
|
+
</originInfo>
|
213
|
+
<originInfo>
|
214
|
+
<place>
|
215
|
+
<placeTerm type="code">us</placeTerm>
|
216
|
+
<placeTerm type="text">[United States]</placeTerm>
|
217
|
+
</place>
|
218
|
+
</originInfo>
|
219
|
+
</mods>
|
220
|
+
MODS
|
221
|
+
end
|
192
222
|
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.3
|
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-08-
|
12
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: stanford-mods
|
@@ -151,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
segments:
|
153
153
|
- 0
|
154
|
-
hash:
|
154
|
+
hash: 1044721319103259075
|
155
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
156
|
none: false
|
157
157
|
requirements:
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
version: '0'
|
161
161
|
segments:
|
162
162
|
- 0
|
163
|
-
hash:
|
163
|
+
hash: 1044721319103259075
|
164
164
|
requirements: []
|
165
165
|
rubyforge_project:
|
166
166
|
rubygems_version: 1.8.25
|