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,16 +0,0 @@
|
|
1
|
-
class ModsDisplay::RelatedLocation < ModsDisplay::Field
|
2
|
-
|
3
|
-
def fields
|
4
|
-
return_fields = @values.map do |value|
|
5
|
-
if value.location.length > 0 and value.titleInfo.length < 1
|
6
|
-
ModsDisplay::Values.new(:label => displayLabel(value), :values => [value.location.text.strip])
|
7
|
-
end
|
8
|
-
end.compact
|
9
|
-
collapse_fields(return_fields)
|
10
|
-
end
|
11
|
-
|
12
|
-
def displayLabel(element)
|
13
|
-
super(element) || "Location"
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
def mods_display_related_location(mods_record)
|
4
|
-
ModsDisplay::RelatedLocation.new(mods_record, ModsDisplay::Configuration::Base.new, mock("controller"))
|
5
|
-
end
|
6
|
-
|
7
|
-
describe ModsDisplay::RelatedLocation do
|
8
|
-
before(:all) do
|
9
|
-
@location = Stanford::Mods::Record.new.from_str("<mods><relatedItem><location>The Location</location></relatedItem></mods>", false).related_item
|
10
|
-
@non_location = Stanford::Mods::Record.new.from_str("<mods><relatedItem><title>No Location</title></relatedItem></mods>", false).related_item
|
11
|
-
@related_item = Stanford::Mods::Record.new.from_str("<mods><relatedItem><titleInfo>Do not display as Related Location</titleInfo><location>The Location</location></relatedItem></mods>", false).related_item
|
12
|
-
@display_label = Stanford::Mods::Record.new.from_str("<mods><relatedItem displayLabel='Special Location'><location>The Location</location></relatedItem></mods>", false).related_item
|
13
|
-
end
|
14
|
-
describe "label" do
|
15
|
-
it "should default to Location" do
|
16
|
-
mods_display_related_location(@location).fields.first.label.should == "Location"
|
17
|
-
end
|
18
|
-
it "should get the displayLabel if available" do
|
19
|
-
mods_display_related_location(@display_label).label.should == "Special Location"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
describe "fields" do
|
23
|
-
it "should get a location if it is available" do
|
24
|
-
fields = mods_display_related_location(@location).fields
|
25
|
-
fields.length.should == 1
|
26
|
-
fields.first.values.should == ["The Location"]
|
27
|
-
end
|
28
|
-
it "should not return any fields if there is no location" do
|
29
|
-
mods_display_related_location(@non_location).fields.should == []
|
30
|
-
end
|
31
|
-
it "should not return locations that are already related items" do
|
32
|
-
mods_display_related_location(@related_item).fields.should == []
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|