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
@@ -1,5 +1,12 @@
|
|
1
1
|
class ModsDisplay::ResourceType < ModsDisplay::Field
|
2
2
|
|
3
|
+
def fields
|
4
|
+
return_fields = @values.map do |value|
|
5
|
+
ModsDisplay::Values.new(:label => displayLabel(value) || label, :values => [value.text.strip.capitalize].flatten)
|
6
|
+
end
|
7
|
+
collapse_fields(return_fields)
|
8
|
+
end
|
9
|
+
|
3
10
|
private
|
4
11
|
def displayLabel(element)
|
5
12
|
super(element) || "Type of resource"
|
data/lib/mods_display/html.rb
CHANGED
@@ -2,7 +2,8 @@ class ModsDisplay::HTML
|
|
2
2
|
attr_reader :title, :body
|
3
3
|
def initialize(config, xml, klass)
|
4
4
|
@config = config
|
5
|
-
@
|
5
|
+
@stanford_mods = xml
|
6
|
+
@xml = xml.mods_ng_xml
|
6
7
|
@klass = klass
|
7
8
|
end
|
8
9
|
|
@@ -21,7 +22,8 @@ class ModsDisplay::HTML
|
|
21
22
|
body_fields = mods_display_fields.dup
|
22
23
|
body_fields[0] = :subTitle
|
23
24
|
body_fields.each do |field_key|
|
24
|
-
|
25
|
+
field = mods_field(@xml, field_key)
|
26
|
+
unless field.nil? or field.to_html.nil?
|
25
27
|
output << mods_field(@xml, field_key).to_html
|
26
28
|
end
|
27
29
|
end
|
@@ -31,8 +33,9 @@ class ModsDisplay::HTML
|
|
31
33
|
def to_html
|
32
34
|
output = "<dl>"
|
33
35
|
mods_display_fields.each do |field_key|
|
34
|
-
|
35
|
-
|
36
|
+
field = mods_field(@xml, field_key)
|
37
|
+
unless field.nil? or field.to_html.nil?
|
38
|
+
output << field.to_html
|
36
39
|
end
|
37
40
|
end
|
38
41
|
output << "</dl>"
|
@@ -52,6 +55,8 @@ class ModsDisplay::HTML
|
|
52
55
|
if xml.respond_to?(mods_display_field_mapping[field_key])
|
53
56
|
field = xml.send(mods_display_field_mapping[field_key])
|
54
57
|
ModsDisplay.const_get("#{field_key.slice(0,1).upcase}#{field_key.slice(1..-1)}").new(field, field_config(field_key), @klass)
|
58
|
+
else @stanford_mods.respond_to?(field_key)
|
59
|
+
ModsDisplay.const_get("#{field_key.slice(0,1).upcase}#{field_key.slice(1..-1)}").new(@stanford_mods, field_config(field_key), @klass)
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
@@ -64,7 +69,7 @@ class ModsDisplay::HTML
|
|
64
69
|
end
|
65
70
|
|
66
71
|
def mods_display_fields
|
67
|
-
[:title, :name, :language, :imprint, :resourceType, :genre, :description, :cartographics, :abstract, :contents, :audience, :note, :contact, :collection, :
|
72
|
+
[:title, :name, :language, :imprint, :resourceType, :genre, :format, :description, :cartographics, :abstract, :contents, :audience, :note, :contact, :collection, :relatedItem, :subject, :identifier, :location, :accessCondition]
|
68
73
|
end
|
69
74
|
|
70
75
|
def mods_display_field_mapping
|
@@ -73,6 +78,7 @@ class ModsDisplay::HTML
|
|
73
78
|
:name => :plain_name,
|
74
79
|
:resourceType => :typeOfResource,
|
75
80
|
:genre => :genre,
|
81
|
+
:format => :format,
|
76
82
|
:imprint => :origin_info,
|
77
83
|
:language => :language,
|
78
84
|
:description => :physical_description,
|
@@ -83,18 +89,18 @@ class ModsDisplay::HTML
|
|
83
89
|
:note => :note,
|
84
90
|
:contact => :note,
|
85
91
|
:collection => :related_item,
|
86
|
-
:relatedLocation => :related_item,
|
87
92
|
:relatedItem => :related_item,
|
88
93
|
:subject => :subject,
|
89
94
|
:identifier => :identifier,
|
90
|
-
:location => :location
|
95
|
+
:location => :location,
|
96
|
+
:accessCondition => :accessCondition}
|
91
97
|
end
|
92
98
|
|
93
99
|
def field_key_translation
|
94
100
|
{:subTitle => :sub_title,
|
95
101
|
:resourceType => :resource_type,
|
96
|
-
:
|
97
|
-
:
|
102
|
+
:relatedItem => :related_item,
|
103
|
+
:accessCondition => :access_condition
|
98
104
|
}
|
99
105
|
end
|
100
106
|
|
@@ -0,0 +1,268 @@
|
|
1
|
+
module ModsDisplay::RelatorCodes
|
2
|
+
def relator_codes
|
3
|
+
{"abr" => "Abridger",
|
4
|
+
"acp" => "Art copyist",
|
5
|
+
"act" => "Actor",
|
6
|
+
"adi" => "Art director",
|
7
|
+
"adp" => "Adapter",
|
8
|
+
"aft" => "Author of afterword, colophon, etc.",
|
9
|
+
"anl" => "Analyst",
|
10
|
+
"anm" => "Animator",
|
11
|
+
"ann" => "Annotator",
|
12
|
+
"ant" => "Bibliographic antecedent",
|
13
|
+
"ape" => "Appellee",
|
14
|
+
"apl" => "Appellant",
|
15
|
+
"app" => "Applicant",
|
16
|
+
"aqt" => "Author in quotations or text abstracts",
|
17
|
+
"arc" => "Architect",
|
18
|
+
"ard" => "Artistic director",
|
19
|
+
"arr" => "Arranger",
|
20
|
+
"art" => "Artist",
|
21
|
+
"asg" => "Assignee",
|
22
|
+
"asn" => "Associated name",
|
23
|
+
"ato" => "Autographer",
|
24
|
+
"att" => "Attributed name",
|
25
|
+
"auc" => "Auctioneer",
|
26
|
+
"aud" => "Author of dialog",
|
27
|
+
"aui" => "Author of introduction, etc.",
|
28
|
+
"aus" => "Screenwriter",
|
29
|
+
"aut" => "Author",
|
30
|
+
"bdd" => "Binding designer",
|
31
|
+
"bjd" => "Bookjacket designer",
|
32
|
+
"bkd" => "Book designer",
|
33
|
+
"bkp" => "Book producer",
|
34
|
+
"blw" => "Blurb writer",
|
35
|
+
"bnd" => "Binder",
|
36
|
+
"bpd" => "Bookplate designer",
|
37
|
+
"brd" => "Broadcaster",
|
38
|
+
"brl" => "Braille embosser",
|
39
|
+
"bsl" => "Bookseller",
|
40
|
+
"cas" => "Caster",
|
41
|
+
"ccp" => "Conceptor",
|
42
|
+
"chr" => "Choreographer",
|
43
|
+
"clb" => "Collaborator",
|
44
|
+
"cli" => "Client",
|
45
|
+
"cll" => "Calligrapher",
|
46
|
+
"clr" => "Colorist",
|
47
|
+
"clt" => "Collotyper",
|
48
|
+
"cmm" => "Commentator",
|
49
|
+
"cmp" => "Composer",
|
50
|
+
"cmt" => "Compositor",
|
51
|
+
"cnd" => "Conductor",
|
52
|
+
"cng" => "Cinematographer",
|
53
|
+
"cns" => "Censor",
|
54
|
+
"coe" => "Contestant-appellee",
|
55
|
+
"col" => "Collector",
|
56
|
+
"com" => "Compiler",
|
57
|
+
"con" => "Conservator",
|
58
|
+
"cor" => "Collection registrar",
|
59
|
+
"cos" => "Contestant",
|
60
|
+
"cot" => "Contestant-appellant",
|
61
|
+
"cou" => "Court governed",
|
62
|
+
"cov" => "Cover designer",
|
63
|
+
"cpc" => "Copyright claimant",
|
64
|
+
"cpe" => "Complainant-appellee",
|
65
|
+
"cph" => "Copyright holder",
|
66
|
+
"cpl" => "Complainant",
|
67
|
+
"cpt" => "Complainant-appellant",
|
68
|
+
"cre" => "Creator",
|
69
|
+
"crp" => "Correspondent",
|
70
|
+
"crr" => "Corrector",
|
71
|
+
"crt" => "Court reporter",
|
72
|
+
"csl" => "Consultant",
|
73
|
+
"csp" => "Consultant to a project",
|
74
|
+
"cst" => "Costume designer",
|
75
|
+
"ctb" => "Contributor",
|
76
|
+
"cte" => "Contestee-appellee",
|
77
|
+
"ctg" => "Cartographer",
|
78
|
+
"ctr" => "Contractor",
|
79
|
+
"cts" => "Contestee",
|
80
|
+
"ctt" => "Contestee-appellant",
|
81
|
+
"cur" => "Curator",
|
82
|
+
"cwt" => "Commentator for written text",
|
83
|
+
"dbp" => "Distribution place",
|
84
|
+
"dfd" => "Defendant",
|
85
|
+
"dfe" => "Defendant-appellee",
|
86
|
+
"dft" => "Defendant-appellant",
|
87
|
+
"dgg" => "Degree granting institution",
|
88
|
+
"dis" => "Dissertant",
|
89
|
+
"dln" => "Delineator",
|
90
|
+
"dnc" => "Dancer",
|
91
|
+
"dnr" => "Donor",
|
92
|
+
"dpc" => "Depicted",
|
93
|
+
"dpt" => "Depositor",
|
94
|
+
"drm" => "Draftsman",
|
95
|
+
"drt" => "Director",
|
96
|
+
"dsr" => "Designer",
|
97
|
+
"dst" => "Distributor",
|
98
|
+
"dtc" => "Data contributor",
|
99
|
+
"dte" => "Dedicatee",
|
100
|
+
"dtm" => "Data manager",
|
101
|
+
"dto" => "Dedicator",
|
102
|
+
"dub" => "Dubious author",
|
103
|
+
"edc" => "Editor of compilation",
|
104
|
+
"edm" => "Editor of moving image work",
|
105
|
+
"edt" => "Editor",
|
106
|
+
"egr" => "Engraver",
|
107
|
+
"elg" => "Electrician",
|
108
|
+
"elt" => "Electrotyper",
|
109
|
+
"eng" => "Engineer",
|
110
|
+
"enj" => "Enacting jurisdiction",
|
111
|
+
"etr" => "Etcher",
|
112
|
+
"evp" => "Event place",
|
113
|
+
"exp" => "Expert",
|
114
|
+
"fac" => "Facsimilist",
|
115
|
+
"fds" => "Film distributor",
|
116
|
+
"fld" => "Field director",
|
117
|
+
"flm" => "Film editor",
|
118
|
+
"fmd" => "Film director",
|
119
|
+
"fmk" => "Filmmaker",
|
120
|
+
"fmo" => "Former owner",
|
121
|
+
"fmp" => "Film producer",
|
122
|
+
"fnd" => "Funder",
|
123
|
+
"fpy" => "First party",
|
124
|
+
"frg" => "Forger",
|
125
|
+
"gis" => "Geographic information specialist",
|
126
|
+
"grt" => "Graphic technician",
|
127
|
+
"his" => "Host institution",
|
128
|
+
"hnr" => "Honoree",
|
129
|
+
"hst" => "Host",
|
130
|
+
"ill" => "Illustrator",
|
131
|
+
"ilu" => "Illuminator",
|
132
|
+
"ins" => "Inscriber",
|
133
|
+
"itr" => "Instrumentalist",
|
134
|
+
"ive" => "Interviewee",
|
135
|
+
"ivr" => "Interviewer",
|
136
|
+
"inv" => "Inventor",
|
137
|
+
"isb" => "Issuing body",
|
138
|
+
"jud" => "Judge",
|
139
|
+
"jug" => "Jurisdiction governed",
|
140
|
+
"lbr" => "Laboratory",
|
141
|
+
"lbt" => "Librettist",
|
142
|
+
"ldr" => "Laboratory director",
|
143
|
+
"led" => "Lead",
|
144
|
+
"lee" => "Libelee-appellee",
|
145
|
+
"lel" => "Libelee",
|
146
|
+
"len" => "Lender",
|
147
|
+
"let" => "Libelee-appellant",
|
148
|
+
"lgd" => "Lighting designer",
|
149
|
+
"lie" => "Libelant-appellee",
|
150
|
+
"lil" => "Libelant",
|
151
|
+
"lit" => "Libelant-appellant",
|
152
|
+
"lsa" => "Landscape architect",
|
153
|
+
"lse" => "Licensee",
|
154
|
+
"lso" => "Licensor",
|
155
|
+
"ltg" => "Lithographer",
|
156
|
+
"lyr" => "Lyricist",
|
157
|
+
"mcp" => "Music copyist",
|
158
|
+
"mdc" => "Metadata contact",
|
159
|
+
"mfp" => "Manufacture place",
|
160
|
+
"mfr" => "Manufacturer",
|
161
|
+
"mod" => "Moderator",
|
162
|
+
"mon" => "Monitor",
|
163
|
+
"mrb" => "Marbler",
|
164
|
+
"mrk" => "Markup editor",
|
165
|
+
"msd" => "Musical director",
|
166
|
+
"mte" => "Metal-engraver",
|
167
|
+
"mus" => "Musician",
|
168
|
+
"nrt" => "Narrator",
|
169
|
+
"opn" => "Opponent",
|
170
|
+
"org" => "Originator",
|
171
|
+
"orm" => "Organizer of meeting",
|
172
|
+
"osp" => "Onscreen presenter",
|
173
|
+
"oth" => "Other",
|
174
|
+
"own" => "Owner",
|
175
|
+
"pan" => "Panelist",
|
176
|
+
"pat" => "Patron",
|
177
|
+
"pbd" => "Publishing director",
|
178
|
+
"pbl" => "Publisher",
|
179
|
+
"pdr" => "Project director",
|
180
|
+
"pfr" => "Proofreader",
|
181
|
+
"pht" => "Photographer",
|
182
|
+
"plt" => "Platemaker",
|
183
|
+
"pma" => "Permitting agency",
|
184
|
+
"pmn" => "Production manager",
|
185
|
+
"pop" => "Printer of plates",
|
186
|
+
"ppm" => "Papermaker",
|
187
|
+
"ppt" => "Puppeteer",
|
188
|
+
"pra" => "Praeses",
|
189
|
+
"prc" => "Process contact",
|
190
|
+
"prd" => "Production personnel",
|
191
|
+
"pre" => "Presenter",
|
192
|
+
"prf" => "Performer",
|
193
|
+
"prg" => "Programmer",
|
194
|
+
"prm" => "Printmaker",
|
195
|
+
"prn" => "Production company",
|
196
|
+
"pro" => "Producer",
|
197
|
+
"prp" => "Production place",
|
198
|
+
"prs" => "Production designer",
|
199
|
+
"prt" => "Printer",
|
200
|
+
"prv" => "Provider",
|
201
|
+
"pta" => "Patent applicant",
|
202
|
+
"pte" => "Plaintiff-appellee",
|
203
|
+
"ptf" => "Plaintiff",
|
204
|
+
"pth" => "Patent holder",
|
205
|
+
"ptt" => "Plaintiff-appellant",
|
206
|
+
"pup" => "Publication place",
|
207
|
+
"rbr" => "Rubricator",
|
208
|
+
"rce" => "Recording engineer",
|
209
|
+
"rcd" => "Recordist",
|
210
|
+
"rcp" => "Addressee",
|
211
|
+
"rdd" => "Radio director",
|
212
|
+
"red" => "Redaktor",
|
213
|
+
"ren" => "Renderer",
|
214
|
+
"res" => "Researcher",
|
215
|
+
"rev" => "Reviewer",
|
216
|
+
"rpc" => "Radio producer",
|
217
|
+
"rps" => "Repository",
|
218
|
+
"rpt" => "Reporter",
|
219
|
+
"rpy" => "Responsible party",
|
220
|
+
"rse" => "Respondent-appellee",
|
221
|
+
"rsg" => "Restager",
|
222
|
+
"rsp" => "Respondent",
|
223
|
+
"rsr" => "Restorationist",
|
224
|
+
"rst" => "Respondent-appellant",
|
225
|
+
"rth" => "Research team head",
|
226
|
+
"rtm" => "Research team member",
|
227
|
+
"sad" => "Scientific advisor",
|
228
|
+
"sce" => "Scenarist",
|
229
|
+
"scl" => "Sculptor",
|
230
|
+
"scr" => "Scribe",
|
231
|
+
"sds" => "Sound designer",
|
232
|
+
"sec" => "Secretary",
|
233
|
+
"sgd" => "Stage director",
|
234
|
+
"sgn" => "Signer",
|
235
|
+
"sht" => "Supporting host",
|
236
|
+
"sll" => "Seller",
|
237
|
+
"sng" => "Singer",
|
238
|
+
"spk" => "Speaker",
|
239
|
+
"spn" => "Sponsor",
|
240
|
+
"spy" => "Second party",
|
241
|
+
"std" => "Set designer",
|
242
|
+
"stg" => "Setting",
|
243
|
+
"stl" => "Storyteller",
|
244
|
+
"stm" => "Stage manager",
|
245
|
+
"stn" => "Standards body",
|
246
|
+
"str" => "Stereotyper",
|
247
|
+
"srv" => "Surveyor",
|
248
|
+
"tcd" => "Technical director",
|
249
|
+
"tch" => "Teacher",
|
250
|
+
"ths" => "Thesis advisor",
|
251
|
+
"tld" => "Television director",
|
252
|
+
"tlp" => "Television producer",
|
253
|
+
"trc" => "Transcriber",
|
254
|
+
"trl" => "Translator",
|
255
|
+
"tyd" => "Type designer",
|
256
|
+
"tyg" => "Typographer",
|
257
|
+
"uvp" => "University place",
|
258
|
+
"vdg" => "Videographer",
|
259
|
+
"voc" => "Vocalist",
|
260
|
+
"wac" => "Writer of added commentary",
|
261
|
+
"wal" => "Writer of added lyrics",
|
262
|
+
"wam" => "Writer of accompanying material",
|
263
|
+
"wat" => "Writer of added text",
|
264
|
+
"wdc" => "Woodcutter",
|
265
|
+
"wde" => "Wood engraver",
|
266
|
+
"wit" => "Witness"}
|
267
|
+
end
|
268
|
+
end
|
data/lib/mods_display/version.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ModsDisplay::Configuration::AccessCondition do
|
4
|
+
it "should default ignore? to true" do
|
5
|
+
ModsDisplay::Configuration::AccessCondition.new.ignore?.should be_true
|
6
|
+
end
|
7
|
+
it "should set ignore? to false when the display! configuration is set" do
|
8
|
+
ModsDisplay::Configuration::AccessCondition.new{ display! }.ignore?.should be_false
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
def mods_display_access_condition(mods_record)
|
4
|
+
ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new, mock("controller"))
|
5
|
+
end
|
6
|
+
def mods_display_versioned_access_condition(mods_record, version)
|
7
|
+
ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new{cc_license_version version}, mock("controller"))
|
8
|
+
end
|
9
|
+
def mods_display_non_ignore_access_condition(mods_record)
|
10
|
+
ModsDisplay::AccessCondition.new(mods_record, ModsDisplay::Configuration::AccessCondition.new{display!}, mock("controller"))
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ModsDisplay::AccessCondition do
|
14
|
+
before :all do
|
15
|
+
@access_condition = Stanford::Mods::Record.new.from_str("<mods><accessCondition>Access Condition Note</accessCondition></mods>", false).accessCondition
|
16
|
+
@restrict_condition = Stanford::Mods::Record.new.from_str("<mods><accessCondition type='restrictionOnAccess'>Restrict Access Note1</accessCondition><accessCondition type='restriction on access'>Restrict Access Note2</accessCondition></mods>", false).accessCondition
|
17
|
+
@copyright_note = Stanford::Mods::Record.new.from_str("<mods><accessCondition type='copyright'>This is a (c) copyright Note. Single instances of (c) should also be replaced in these notes.</accessCondition></mods>", false).accessCondition
|
18
|
+
@cc_license_note = Stanford::Mods::Record.new.from_str("<mods><accessCondition type='license'>CC by-sa: This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License</accessCondition></mods>", false).accessCondition
|
19
|
+
@odc_license_note = Stanford::Mods::Record.new.from_str("<mods><accessCondition type='license'>ODC pddl: This work is licensed under a Open Data Commons Public Domain Dedication and License (PDDL)</accessCondition></mods>", false).accessCondition
|
20
|
+
@no_link_license_note = Stanford::Mods::Record.new.from_str("<mods><accessCondition type='license'>Unknown something: This work is licensed under an Unknown License and will not be linked</accessCondition></mods>", false).accessCondition
|
21
|
+
end
|
22
|
+
describe "labels" do
|
23
|
+
it "should normalize types and assign proper labels" do
|
24
|
+
fields = mods_display_access_condition(@restrict_condition).fields
|
25
|
+
fields.length.should == 1
|
26
|
+
fields.first.label.should == "Restriction on access"
|
27
|
+
fields.first.values.each_with_index do |value, index|
|
28
|
+
value.should match /^Restrict Access Note#{index+1}/
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe "fields" do
|
33
|
+
describe "copyright" do
|
34
|
+
it "should replace instances of '(c) copyright' with the HTML copyright entity" do
|
35
|
+
fields = mods_display_access_condition(@copyright_note).fields
|
36
|
+
fields.length.should == 1
|
37
|
+
fields.first.values.length.should == 1
|
38
|
+
fields.first.values.first.should == "This is a © Note. Single instances of © should also be replaced in these notes."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
describe "licenses" do
|
42
|
+
it "should add the appropriate classes to the html around the license" do
|
43
|
+
fields = mods_display_access_condition(@no_link_license_note).fields
|
44
|
+
fields.length.should == 1
|
45
|
+
fields.first.values.length.should == 1
|
46
|
+
fields.first.values.first.should match /^<div class='unknown-something'>.*<\/div>$/
|
47
|
+
end
|
48
|
+
it "should itentify and link CreativeCommons licenses properly" do
|
49
|
+
fields = mods_display_access_condition(@cc_license_note).fields
|
50
|
+
fields.length.should == 1
|
51
|
+
fields.first.values.length.should == 1
|
52
|
+
fields.first.values.first.should include("<a href='http://creativecommons.org/licenses/by-sa/3.0/'>This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License</a>")
|
53
|
+
end
|
54
|
+
it "should itentify and link OpenDataCommons licenses properly" do
|
55
|
+
fields = mods_display_access_condition(@odc_license_note).fields
|
56
|
+
fields.length.should == 1
|
57
|
+
fields.first.values.length.should == 1
|
58
|
+
fields.first.values.first.should include("<a href='http://opendatacommons.org/licenses/pddl'>This work is licensed under a Open Data Commons Public Domain Dedication and License (PDDL)</a>")
|
59
|
+
end
|
60
|
+
it "should have a configurable version for CC licenses" do
|
61
|
+
fields = mods_display_versioned_access_condition(@cc_license_note, "4.0").fields
|
62
|
+
fields.length.should == 1
|
63
|
+
fields.first.values.length.should == 1
|
64
|
+
fields.first.values.first.should include("http://creativecommons.org/licenses/by-sa/4.0/")
|
65
|
+
fields.first.values.first.should_not include("http://creativecommons.org/licenses/by-sa/3.0/")
|
66
|
+
end
|
67
|
+
it "should not apply configured version to NON-CC licenses" do
|
68
|
+
fields = mods_display_versioned_access_condition(@odc_license_note, "4.0").fields
|
69
|
+
fields.length.should == 1
|
70
|
+
fields.first.values.length.should == 1
|
71
|
+
fields.first.values.first.should_not include("/4.0/")
|
72
|
+
end
|
73
|
+
it "should not attempt unknown license types" do
|
74
|
+
fields = mods_display_access_condition(@no_link_license_note).fields
|
75
|
+
fields.length.should == 1
|
76
|
+
fields.first.values.length.should == 1
|
77
|
+
fields.first.values.first.should include("This work is licensed under an Unknown License and will not be linked")
|
78
|
+
fields.first.values.first.should_not include("<a.*>")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
describe "to_html" do
|
83
|
+
it "should ignore access conditions by default" do
|
84
|
+
mods_display_access_condition(@access_condition).to_html.should be_nil
|
85
|
+
end
|
86
|
+
it "should not ignore the access condition when ignore is set to false" do
|
87
|
+
html = mods_display_non_ignore_access_condition(@access_condition).to_html
|
88
|
+
html.should match /<dt.*>Access condition:<\/dt><dd>Access Condition Note<\/dd>/
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|