mods_display 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +16 -0
- data/.rubocop_todo.yml +60 -0
- data/.travis.yml +2 -2
- data/Rakefile +10 -2
- data/lib/mods_display.rb +42 -42
- data/lib/mods_display/configuration.rb +69 -67
- data/lib/mods_display/configuration/access_condition.rb +17 -13
- data/lib/mods_display/configuration/base.rb +27 -24
- data/lib/mods_display/configuration/format.rb +8 -4
- data/lib/mods_display/configuration/genre.rb +8 -4
- data/lib/mods_display/configuration/imprint.rb +12 -7
- data/lib/mods_display/configuration/name.rb +8 -4
- data/lib/mods_display/configuration/note.rb +8 -4
- data/lib/mods_display/configuration/related_item.rb +8 -4
- data/lib/mods_display/configuration/subject.rb +11 -9
- data/lib/mods_display/configuration/title.rb +8 -4
- data/lib/mods_display/controller_extension.rb +24 -24
- data/lib/mods_display/country_codes.rb +385 -384
- data/lib/mods_display/fields/abstract.rb +7 -6
- data/lib/mods_display/fields/access_condition.rb +55 -55
- data/lib/mods_display/fields/audience.rb +7 -6
- data/lib/mods_display/fields/cartographics.rb +15 -14
- data/lib/mods_display/fields/collection.rb +32 -17
- data/lib/mods_display/fields/contact.rb +15 -13
- data/lib/mods_display/fields/contents.rb +7 -6
- data/lib/mods_display/fields/description.rb +21 -21
- data/lib/mods_display/fields/field.rb +164 -109
- data/lib/mods_display/fields/format.rb +36 -33
- data/lib/mods_display/fields/genre.rb +12 -11
- data/lib/mods_display/fields/identifier.rb +34 -34
- data/lib/mods_display/fields/imprint.rb +258 -214
- data/lib/mods_display/fields/language.rb +18 -16
- data/lib/mods_display/fields/location.rb +27 -26
- data/lib/mods_display/fields/name.rb +113 -118
- data/lib/mods_display/fields/note.rb +33 -34
- data/lib/mods_display/fields/related_item.rb +64 -66
- data/lib/mods_display/fields/resource_type.rb +13 -11
- data/lib/mods_display/fields/sub_title.rb +6 -4
- data/lib/mods_display/fields/subject.rb +92 -90
- data/lib/mods_display/fields/title.rb +54 -49
- data/lib/mods_display/fields/values.rb +7 -8
- data/lib/mods_display/html.rb +117 -96
- data/lib/mods_display/model_extension.rb +17 -16
- data/lib/mods_display/relator_codes.rb +269 -267
- data/lib/mods_display/version.rb +1 -1
- data/mods_display.gemspec +13 -12
- data/spec/configuration/access_condition_spec.rb +5 -5
- data/spec/configuration/base_spec.rb +24 -24
- data/spec/fields/abstract_spec.rb +24 -14
- data/spec/fields/access_condition_spec.rb +80 -55
- data/spec/fields/audience_spec.rb +15 -12
- data/spec/fields/cartographics_spec.rb +17 -18
- data/spec/fields/collection_spec.rb +65 -19
- data/spec/fields/contact_spec.rb +11 -9
- data/spec/fields/contents_spec.rb +15 -12
- data/spec/fields/description_spec.rb +40 -22
- data/spec/fields/format_spec.rb +28 -18
- data/spec/fields/genre_spec.rb +18 -16
- data/spec/fields/identifier_spec.rb +46 -34
- data/spec/fields/imprint_spec.rb +151 -125
- data/spec/fields/language_spec.rb +36 -20
- data/spec/fields/location_spec.rb +43 -27
- data/spec/fields/name_spec.rb +92 -92
- data/spec/fields/note_spec.rb +53 -40
- data/spec/fields/related_item_spec.rb +42 -40
- data/spec/fields/resource_type_spec.rb +20 -14
- data/spec/fields/sub_title_spec.rb +11 -9
- data/spec/fields/subject_spec.rb +61 -56
- data/spec/fields/title_spec.rb +53 -40
- data/spec/fixtures/access_condition_fixtures.rb +50 -0
- data/spec/fixtures/cartographics_fixtures.rb +1 -1
- data/spec/fixtures/imprint_fixtures.rb +49 -1
- data/spec/fixtures/name_fixtures.rb +195 -2
- data/spec/fixtures/related_item_fixtures.rb +107 -0
- data/spec/fixtures/subjects_fixtures.rb +15 -2
- data/spec/fixtures/title_fixtures.rb +101 -0
- data/spec/integration/configuration_spec.rb +23 -20
- data/spec/integration/html_spec.rb +40 -29
- data/spec/integration/installation_spec.rb +14 -14
- data/spec/spec_helper.rb +5 -8
- metadata +25 -3
data/lib/mods_display/version.rb
CHANGED
data/mods_display.gemspec
CHANGED
@@ -4,22 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'mods_display/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name =
|
7
|
+
gem.name = 'mods_display'
|
8
8
|
gem.version = ModsDisplay::VERSION
|
9
|
-
gem.authors = [
|
10
|
-
gem.email = [
|
11
|
-
gem.description =
|
12
|
-
gem.summary =
|
13
|
-
gem.homepage =
|
9
|
+
gem.authors = ['Jessie Keck']
|
10
|
+
gem.email = ['jessie.keck@gmail.com']
|
11
|
+
gem.description = 'MODS Display is a gem to centralize the display logic of MODS medadata.'
|
12
|
+
gem.summary = 'The MODS Display gem allows implementers to configure a customized display of MODS metadata. This display implements the specifications defined at Stanford for how to display MODS.'
|
13
|
+
gem.homepage = 'https://github.com/sul-dlss/mods_display'
|
14
14
|
|
15
|
-
gem.files = `git ls-files`.split(
|
16
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(spec)/})
|
18
|
-
gem.require_paths = [
|
19
|
-
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
|
20
20
|
gem.add_dependency 'stanford-mods'
|
21
21
|
gem.add_dependency 'i18n'
|
22
|
-
|
22
|
+
|
23
23
|
gem.add_development_dependency 'rake'
|
24
|
-
gem.add_development_dependency 'rspec'
|
24
|
+
gem.add_development_dependency 'rspec', '~> 3.0'
|
25
|
+
gem.add_development_dependency 'rubocop'
|
25
26
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ModsDisplay::Configuration::AccessCondition do
|
4
|
-
it
|
5
|
-
ModsDisplay::Configuration::AccessCondition.new.ignore
|
4
|
+
it 'should default ignore? to true' do
|
5
|
+
expect(ModsDisplay::Configuration::AccessCondition.new.ignore?).to be true
|
6
6
|
end
|
7
|
-
it
|
8
|
-
ModsDisplay::Configuration::AccessCondition.new{ display! }.ignore
|
7
|
+
it 'should set ignore? to false when the display! configuration is set' do
|
8
|
+
expect(ModsDisplay::Configuration::AccessCondition.new { display! }.ignore?).to be false
|
9
9
|
end
|
10
10
|
end
|
@@ -1,39 +1,39 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ModsDisplay::Configuration::Base do
|
4
|
-
it
|
5
|
-
config = ModsDisplay::Configuration::Base.new do
|
6
|
-
label_class
|
7
|
-
value_class
|
4
|
+
it 'should set config options w/ a block' do
|
5
|
+
config = ModsDisplay::Configuration::Base.new do
|
6
|
+
label_class 'testing_label_class'
|
7
|
+
value_class 'testing_value_class'
|
8
8
|
end
|
9
|
-
config.label_class.
|
10
|
-
config.value_class.
|
9
|
+
expect(config.label_class).to eq('testing_label_class')
|
10
|
+
expect(config.value_class).to eq('testing_value_class')
|
11
11
|
end
|
12
|
-
describe
|
13
|
-
it
|
14
|
-
ModsDisplay::Configuration::Base.new do
|
12
|
+
describe 'link' do
|
13
|
+
it 'should return an array with a method name and params' do
|
14
|
+
expect(ModsDisplay::Configuration::Base.new do
|
15
15
|
link :my_url_generating_method, q: '"%value%"'
|
16
|
-
end.link.
|
16
|
+
end.link).to eq([:my_url_generating_method, { q: '"%value%"' }])
|
17
17
|
end
|
18
18
|
end
|
19
|
-
describe
|
20
|
-
it
|
21
|
-
ModsDisplay::Configuration::Base.new do
|
22
|
-
delimiter
|
23
|
-
end.delimiter.
|
19
|
+
describe 'delmiter' do
|
20
|
+
it 'should override the default delimiter' do
|
21
|
+
expect(ModsDisplay::Configuration::Base.new do
|
22
|
+
delimiter '<br/>'
|
23
|
+
end.delimiter).to eq('<br/>')
|
24
24
|
end
|
25
25
|
it "should default to ', '" do
|
26
|
-
ModsDisplay::Configuration::Base.new.delimiter.
|
26
|
+
expect(ModsDisplay::Configuration::Base.new.delimiter).to eq(', ')
|
27
27
|
end
|
28
28
|
end
|
29
|
-
describe
|
30
|
-
it
|
31
|
-
ModsDisplay::Configuration::Base.new do
|
29
|
+
describe 'ignore' do
|
30
|
+
it 'should be set to true if the #ignore! method is called' do
|
31
|
+
expect(ModsDisplay::Configuration::Base.new do
|
32
32
|
ignore!
|
33
|
-
end.ignore
|
33
|
+
end.ignore?).to be true
|
34
34
|
end
|
35
|
-
it
|
36
|
-
ModsDisplay::Configuration::Base.new.ignore
|
35
|
+
it 'should be false by default' do
|
36
|
+
expect(ModsDisplay::Configuration::Base.new.ignore?).to be false
|
37
37
|
end
|
38
38
|
end
|
39
|
-
end
|
39
|
+
end
|
@@ -1,29 +1,39 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
def mods_display_abstract(mods_record)
|
4
|
-
ModsDisplay::Abstract.new(mods_record, ModsDisplay::Configuration::Base.new, double(
|
4
|
+
ModsDisplay::Abstract.new(mods_record, ModsDisplay::Configuration::Base.new, double('controller'))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Abstract do
|
8
8
|
before(:all) do
|
9
|
-
@link = Stanford::Mods::Record.new.from_str(
|
10
|
-
|
9
|
+
@link = Stanford::Mods::Record.new.from_str(
|
10
|
+
'<mods><abstract>A link to the library (http://library.stanford.edu) should appear here</abstract></mods>', false
|
11
|
+
).abstract
|
12
|
+
@email = Stanford::Mods::Record.new.from_str(
|
13
|
+
'<mods><abstract>A link to an email address jdoe@example.com should appear here</abstract></mods>', false
|
14
|
+
).abstract
|
11
15
|
end
|
12
|
-
|
13
|
-
describe
|
16
|
+
|
17
|
+
describe 'labels' do
|
14
18
|
it "should get a default 'Abstract' label" do
|
15
19
|
fields = mods_display_abstract(@link).fields
|
16
|
-
fields.length.
|
17
|
-
fields.first.label.
|
20
|
+
expect(fields.length).to eq(1)
|
21
|
+
expect(fields.first.label).to eq('Abstract:')
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
|
-
describe
|
22
|
-
it
|
23
|
-
mods_display_abstract(@link).to_html.
|
25
|
+
describe 'links' do
|
26
|
+
it 'should turn URLs into links' do
|
27
|
+
expect(mods_display_abstract(@link).to_html).to match(/A link to the library \(<a href/)
|
28
|
+
expect(mods_display_abstract(@link).to_html).to match(
|
29
|
+
%r{\(<a href='http://library.stanford.edu'>http://library.stanford.edu</a>\)}
|
30
|
+
)
|
31
|
+
expect(mods_display_abstract(@link).to_html).to match(%r{</a>\) should appear here})
|
24
32
|
end
|
25
|
-
it
|
26
|
-
mods_display_abstract(@email).to_html.
|
33
|
+
it 'should turn email addresses into mailto links' do
|
34
|
+
expect(mods_display_abstract(@email).to_html).to match(
|
35
|
+
%r{A link to an email address <a href='mailto:jdoe@example.com'>jdoe@example.com</a> should appear here}
|
36
|
+
)
|
27
37
|
end
|
28
38
|
end
|
29
|
-
end
|
39
|
+
end
|
@@ -1,91 +1,116 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
def mods_display_access_condition(mods_record)
|
4
|
-
ModsDisplay::AccessCondition.new(
|
4
|
+
ModsDisplay::AccessCondition.new(
|
5
|
+
mods_record,
|
6
|
+
ModsDisplay::Configuration::AccessCondition.new,
|
7
|
+
double('controller')
|
8
|
+
)
|
5
9
|
end
|
10
|
+
|
6
11
|
def mods_display_versioned_access_condition(mods_record, version)
|
7
|
-
ModsDisplay::AccessCondition.new(
|
12
|
+
ModsDisplay::AccessCondition.new(
|
13
|
+
mods_record,
|
14
|
+
ModsDisplay::Configuration::AccessCondition.new { cc_license_version version },
|
15
|
+
double('controller')
|
16
|
+
)
|
8
17
|
end
|
18
|
+
|
9
19
|
def mods_display_non_ignore_access_condition(mods_record)
|
10
|
-
ModsDisplay::AccessCondition.new(
|
20
|
+
ModsDisplay::AccessCondition.new(
|
21
|
+
mods_record,
|
22
|
+
ModsDisplay::Configuration::AccessCondition.new { display! },
|
23
|
+
double('controller')
|
24
|
+
)
|
11
25
|
end
|
12
26
|
|
13
27
|
describe ModsDisplay::AccessCondition do
|
28
|
+
include AccessConditionFixtures
|
14
29
|
before :all do
|
15
|
-
@access_condition = Stanford::Mods::Record.new.from_str(
|
16
|
-
@restrict_condition = Stanford::Mods::Record.new.from_str(
|
17
|
-
@copyright_note = Stanford::Mods::Record.new.from_str(
|
18
|
-
@cc_license_note = Stanford::Mods::Record.new.from_str(
|
19
|
-
@odc_license_note = Stanford::Mods::Record.new.from_str(
|
20
|
-
@no_link_license_note = Stanford::Mods::Record.new.from_str(
|
30
|
+
@access_condition = Stanford::Mods::Record.new.from_str(simple_access_condition_fixture, false).accessCondition
|
31
|
+
@restrict_condition = Stanford::Mods::Record.new.from_str(restricted_access_fixture, false).accessCondition
|
32
|
+
@copyright_note = Stanford::Mods::Record.new.from_str(copyright_access_fixture, false).accessCondition
|
33
|
+
@cc_license_note = Stanford::Mods::Record.new.from_str(cc_license_fixture, false).accessCondition
|
34
|
+
@odc_license_note = Stanford::Mods::Record.new.from_str(odc_license_fixture, false).accessCondition
|
35
|
+
@no_link_license_note = Stanford::Mods::Record.new.from_str(no_license_fixture, false).accessCondition
|
21
36
|
end
|
22
|
-
describe
|
23
|
-
it
|
37
|
+
describe 'labels' do
|
38
|
+
it 'should normalize types and assign proper labels' do
|
24
39
|
fields = mods_display_access_condition(@restrict_condition).fields
|
25
|
-
fields.length.
|
26
|
-
fields.first.label.
|
40
|
+
expect(fields.length).to eq(1)
|
41
|
+
expect(fields.first.label).to eq('Restriction on access:')
|
27
42
|
fields.first.values.each_with_index do |value, index|
|
28
|
-
value.
|
43
|
+
expect(value).to match(/^Restrict Access Note#{index + 1}/)
|
29
44
|
end
|
30
45
|
end
|
31
46
|
end
|
32
|
-
describe
|
33
|
-
describe
|
47
|
+
describe 'fields' do
|
48
|
+
describe 'copyright' do
|
34
49
|
it "should replace instances of '(c) copyright' with the HTML copyright entity" do
|
35
50
|
fields = mods_display_access_condition(@copyright_note).fields
|
36
|
-
fields.length.
|
37
|
-
fields.first.values.length.
|
38
|
-
fields.first.values.first.
|
51
|
+
expect(fields.length).to eq(1)
|
52
|
+
expect(fields.first.values.length).to eq(1)
|
53
|
+
expect(fields.first.values.first).to eq(
|
54
|
+
'This is a © Note. Single instances of © should also be replaced in these notes.'
|
55
|
+
)
|
39
56
|
end
|
40
57
|
end
|
41
|
-
describe
|
42
|
-
it
|
58
|
+
describe 'licenses' do
|
59
|
+
it 'should add the appropriate classes to the html around the license' do
|
43
60
|
fields = mods_display_access_condition(@no_link_license_note).fields
|
44
|
-
fields.length.
|
45
|
-
fields.first.values.length.
|
46
|
-
fields.first.values.first.
|
61
|
+
expect(fields.length).to eq(1)
|
62
|
+
expect(fields.first.values.length).to eq(1)
|
63
|
+
expect(fields.first.values.first).to match(%r{^<div class='unknown-something'>.*</div>$})
|
47
64
|
end
|
48
|
-
it
|
65
|
+
it 'should itentify and link CreativeCommons licenses properly' do
|
49
66
|
fields = mods_display_access_condition(@cc_license_note).fields
|
50
|
-
fields.length.
|
51
|
-
fields.first.values.length.
|
52
|
-
fields.first.values.first.
|
67
|
+
expect(fields.length).to eq(1)
|
68
|
+
expect(fields.first.values.length).to eq(1)
|
69
|
+
expect(fields.first.values.first).to include("<a href='http://creativecommons.org/licenses/by-sa/3.0/'>")
|
70
|
+
expect(fields.first.values.first).to include(
|
71
|
+
'This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License'
|
72
|
+
)
|
53
73
|
end
|
54
|
-
it
|
74
|
+
it 'should itentify and link OpenDataCommons licenses properly' do
|
55
75
|
fields = mods_display_access_condition(@odc_license_note).fields
|
56
|
-
fields.length.
|
57
|
-
fields.first.values.length.
|
58
|
-
fields.first.values.first.
|
76
|
+
expect(fields.length).to eq(1)
|
77
|
+
expect(fields.first.values.length).to eq(1)
|
78
|
+
expect(fields.first.values.first).to include("<a href='http://opendatacommons.org/licenses/pddl'>")
|
79
|
+
expect(fields.first.values.first).to include(
|
80
|
+
'This work is licensed under a Open Data Commons Public Domain Dedication and License (PDDL)'
|
81
|
+
)
|
59
82
|
end
|
60
|
-
it
|
61
|
-
fields = mods_display_versioned_access_condition(@cc_license_note,
|
62
|
-
fields.length.
|
63
|
-
fields.first.values.length.
|
64
|
-
fields.first.values.first.
|
65
|
-
fields.first.values.first.
|
83
|
+
it 'should have a configurable version for CC licenses' do
|
84
|
+
fields = mods_display_versioned_access_condition(@cc_license_note, '4.0').fields
|
85
|
+
expect(fields.length).to eq(1)
|
86
|
+
expect(fields.first.values.length).to eq(1)
|
87
|
+
expect(fields.first.values.first).to include('http://creativecommons.org/licenses/by-sa/4.0/')
|
88
|
+
expect(fields.first.values.first).not_to include('http://creativecommons.org/licenses/by-sa/3.0/')
|
66
89
|
end
|
67
|
-
it
|
68
|
-
fields = mods_display_versioned_access_condition(@odc_license_note,
|
69
|
-
fields.length.
|
70
|
-
fields.first.values.length.
|
71
|
-
fields.first.values.first.
|
90
|
+
it 'should not apply configured version to NON-CC licenses' do
|
91
|
+
fields = mods_display_versioned_access_condition(@odc_license_note, '4.0').fields
|
92
|
+
expect(fields.length).to eq(1)
|
93
|
+
expect(fields.first.values.length).to eq(1)
|
94
|
+
expect(fields.first.values.first).not_to include('/4.0/')
|
72
95
|
end
|
73
|
-
it
|
96
|
+
it 'should not attempt unknown license types' do
|
74
97
|
fields = mods_display_access_condition(@no_link_license_note).fields
|
75
|
-
fields.length.
|
76
|
-
fields.first.values.length.
|
77
|
-
fields.first.values.first.
|
78
|
-
|
98
|
+
expect(fields.length).to eq(1)
|
99
|
+
expect(fields.first.values.length).to eq(1)
|
100
|
+
expect(fields.first.values.first).to include(
|
101
|
+
'This work is licensed under an Unknown License and will not be linked'
|
102
|
+
)
|
103
|
+
expect(fields.first.values.first).not_to include('<a.*>')
|
79
104
|
end
|
80
105
|
end
|
81
106
|
end
|
82
|
-
describe
|
83
|
-
it
|
84
|
-
mods_display_access_condition(@access_condition).to_html.
|
107
|
+
describe 'to_html' do
|
108
|
+
it 'should ignore access conditions by default' do
|
109
|
+
expect(mods_display_access_condition(@access_condition).to_html).to be_nil
|
85
110
|
end
|
86
|
-
it
|
111
|
+
it 'should not ignore the access condition when ignore is set to false' do
|
87
112
|
html = mods_display_non_ignore_access_condition(@access_condition).to_html
|
88
|
-
html.
|
113
|
+
expect(html).to match %r{<dt.*>Access condition:</dt><dd>Access Condition Note</dd>}
|
89
114
|
end
|
90
115
|
end
|
91
|
-
end
|
116
|
+
end
|
@@ -1,21 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
def mods_display_audience(mods_record)
|
4
|
-
ModsDisplay::Audience.new(mods_record, ModsDisplay::Configuration::Base.new, double(
|
4
|
+
ModsDisplay::Audience.new(mods_record, ModsDisplay::Configuration::Base.new, double('controller'))
|
5
5
|
end
|
6
6
|
|
7
7
|
describe ModsDisplay::Contents do
|
8
8
|
before(:all) do
|
9
|
-
@audience = Stanford::Mods::Record.new.from_str(
|
10
|
-
|
9
|
+
@audience = Stanford::Mods::Record.new.from_str(
|
10
|
+
'<mods><targetAudience>Audience Note</targetAudience></mods>', false
|
11
|
+
).targetAudience
|
12
|
+
@display_label = Stanford::Mods::Record.new.from_str(
|
13
|
+
"<mods><targetAudience displayLabel='Special Label'>Audience Note</tableOfContents></mods>", false
|
14
|
+
).targetAudience
|
11
15
|
end
|
12
|
-
describe
|
13
|
-
it
|
14
|
-
mods_display_audience(@audience).label.
|
16
|
+
describe 'label' do
|
17
|
+
it 'should have a default label' do
|
18
|
+
expect(mods_display_audience(@audience).label).to eq('Target audience:')
|
15
19
|
end
|
16
|
-
it
|
17
|
-
mods_display_audience(@display_label).label.
|
20
|
+
it 'should use the displayLabel attribute when one is available' do
|
21
|
+
expect(mods_display_audience(@display_label).label).to eq('Special Label:')
|
18
22
|
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/cartographics_fixtures'
|
3
3
|
include CartographicsFixtures
|
4
4
|
|
5
5
|
def mods_display_cartographics(mods)
|
6
|
-
ModsDisplay::Cartographics.new(mods, ModsDisplay::Configuration::Base.new, double(
|
6
|
+
ModsDisplay::Cartographics.new(mods, ModsDisplay::Configuration::Base.new, double('controller'))
|
7
7
|
end
|
8
8
|
|
9
9
|
describe ModsDisplay::Cartographics do
|
@@ -13,27 +13,26 @@ describe ModsDisplay::Cartographics do
|
|
13
13
|
@no_scale = Stanford::Mods::Record.new.from_str(no_scale_cartographic, false).subject
|
14
14
|
@coordinates = Stanford::Mods::Record.new.from_str(coordinates_only, false).subject
|
15
15
|
end
|
16
|
-
describe
|
17
|
-
it
|
16
|
+
describe 'values' do
|
17
|
+
it 'should get the full cartographic note' do
|
18
18
|
values = mods_display_cartographics(@cart).fields
|
19
|
-
values.length.
|
20
|
-
values.first.values.
|
19
|
+
expect(values.length).to eq(1)
|
20
|
+
expect(values.first.values).to eq(['The scale ; the projection the coordinates'])
|
21
21
|
end
|
22
|
-
it
|
22
|
+
it 'should put a scale not given note if no scale is present' do
|
23
23
|
values = mods_display_cartographics(@no_scale).fields
|
24
|
-
values.length.
|
25
|
-
values.first.values.
|
24
|
+
expect(values.length).to eq(1)
|
25
|
+
expect(values.first.values).to eq(['Scale not given ; the projection the coordinates'])
|
26
26
|
end
|
27
|
-
it
|
27
|
+
it 'should handle when there is only a scale note' do
|
28
28
|
values = mods_display_cartographics(@scale_only).fields
|
29
|
-
values.length.
|
30
|
-
values.first.values.
|
29
|
+
expect(values.length).to eq(1)
|
30
|
+
expect(values.first.values).to eq(['The scale'])
|
31
31
|
end
|
32
|
-
it
|
32
|
+
it 'should handle when only one post-scale piece of the data is available' do
|
33
33
|
values = mods_display_cartographics(@coordinates).fields
|
34
|
-
values.length.
|
35
|
-
values.first.values.
|
34
|
+
expect(values.length).to eq(1)
|
35
|
+
expect(values.first.values).to eq(['Scale not given ; the coordinates'])
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
39
|
-
end
|
38
|
+
end
|
@@ -1,31 +1,77 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
def mods_display_collection(mods_record)
|
4
|
-
ModsDisplay::Collection.new(
|
4
|
+
ModsDisplay::Collection.new(
|
5
|
+
mods_record,
|
6
|
+
ModsDisplay::Configuration::Base.new,
|
7
|
+
double('controller')
|
8
|
+
)
|
5
9
|
end
|
6
10
|
|
7
11
|
describe ModsDisplay::Collection do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
let(:collection) do
|
13
|
+
Stanford::Mods::Record.new.from_str(
|
14
|
+
'<mods>
|
15
|
+
<relatedItem>
|
16
|
+
<titleInfo><title>The Collection</title></titleInfo><typeOfResource collection="yes" />
|
17
|
+
</relatedItem>
|
18
|
+
</mods>',
|
19
|
+
false
|
20
|
+
).related_item
|
12
21
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
22
|
+
let(:non_collection) do
|
23
|
+
Stanford::Mods::Record.new.from_str(
|
24
|
+
'<mods><relatedItem><titleInfo><title>Not a Collection</title></titleInfo></relatedItem></mods>',
|
25
|
+
false
|
26
|
+
).related_item
|
27
|
+
end
|
28
|
+
let(:display_label) do
|
29
|
+
Stanford::Mods::Record.new.from_str(
|
30
|
+
'<mods>
|
31
|
+
<relatedItem displayLabel="Special Collection">
|
32
|
+
<titleInfo><title>Not a Collection</title></titleInfo>
|
33
|
+
</relatedItem>
|
34
|
+
</mods>',
|
35
|
+
false
|
36
|
+
).related_item
|
37
|
+
end
|
38
|
+
let(:multiple_related_items) do
|
39
|
+
Stanford::Mods::Record.new.from_str(
|
40
|
+
'<mods>
|
41
|
+
<relatedItem displayLabel="Special Collection">
|
42
|
+
<titleInfo><title>Not a Collection</title></titleInfo>
|
43
|
+
</relatedItem>
|
44
|
+
<relatedItem>
|
45
|
+
<titleInfo><title>The Collection</title></titleInfo><typeOfResource collection="yes" />
|
46
|
+
</relatedItem>
|
47
|
+
</mods>',
|
48
|
+
false
|
49
|
+
).related_item
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'label' do
|
53
|
+
it 'should default to Collection' do
|
54
|
+
expect(mods_display_collection(collection).fields.first.label).to eq('Collection:')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should get the displayLabel if available' do
|
58
|
+
expect(mods_display_collection(display_label).label).to eq('Special Collection:')
|
16
59
|
end
|
17
|
-
|
18
|
-
|
60
|
+
|
61
|
+
it 'should get the proper titles of all items when there is a displayLabel present' do
|
62
|
+
expect(mods_display_collection(multiple_related_items).fields.first.label).to eq 'Collection:'
|
19
63
|
end
|
20
64
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
fields
|
25
|
-
fields.
|
65
|
+
|
66
|
+
describe 'fields' do
|
67
|
+
it 'should get a collection title if there is an appropriate typeOfResource field with the collection attribute' do
|
68
|
+
fields = mods_display_collection(collection).fields
|
69
|
+
expect(fields.length).to eq(1)
|
70
|
+
expect(fields.first.values).to eq(['The Collection'])
|
26
71
|
end
|
27
|
-
|
28
|
-
|
72
|
+
|
73
|
+
it 'should be blank if the there is not an appropriate typeOfResource field with the collection attribute' do
|
74
|
+
expect(mods_display_collection(non_collection).fields).to eq([])
|
29
75
|
end
|
30
76
|
end
|
31
|
-
end
|
77
|
+
end
|