mods_display 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +64 -9
- data/.travis.yml +0 -1
- data/Rakefile +5 -1
- data/config/locales/en.yml +3 -1
- data/lib/mods_display.rb +3 -2
- data/lib/mods_display/configuration.rb +0 -4
- data/lib/mods_display/fields/extent.rb +19 -0
- data/lib/mods_display/fields/form.rb +19 -0
- data/lib/mods_display/fields/geo.rb +30 -0
- data/lib/mods_display/html.rb +6 -2
- data/lib/mods_display/version.rb +1 -1
- data/mods_display.gemspec +2 -1
- data/spec/fields/extent_spec.rb +30 -0
- data/spec/fields/form_spec.rb +30 -0
- data/spec/fields/geo_spec.rb +40 -0
- data/spec/fields/location_spec.rb +52 -31
- metadata +15 -10
- data/lib/mods_display/configuration/format.rb +0 -9
- data/lib/mods_display/fields/format.rb +0 -45
- data/spec/fields/format_spec.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5341a52d7bf05861b22abcee4950b5d0a45f6d0b
|
4
|
+
data.tar.gz: cd919cf57341abbe5c5fc46c3d8ce755e8ee780c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7068515bccf5840a7c008d395f356a8b6c2695794dc4ec3aff1c85c24d84b535444db592ac2494e314db6f764746839b5d8fe0a7628b8cd705130adc427b9af2
|
7
|
+
data.tar.gz: ceff1ea49af522991dd8dc7048a4642df4aff43409a5f31a97907e6d91c2b23ec42ff36a9726a054712e9d4a410a2417288e310919c6b583758c0e8317fb0921
|
data/.rubocop_todo.yml
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2016-02-17 16:15:37 -0800 using RuboCop version 0.37.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
Lint/
|
9
|
+
# Offense count: 1
|
10
|
+
Lint/UselessAccessModifier:
|
11
11
|
Exclude:
|
12
12
|
- 'lib/mods_display/controller_extension.rb'
|
13
|
-
- 'lib/mods_display/model_extension.rb'
|
14
13
|
|
15
|
-
# Offense count:
|
14
|
+
# Offense count: 28
|
16
15
|
Metrics/AbcSize:
|
17
16
|
Max: 55
|
18
17
|
|
@@ -21,11 +20,11 @@ Metrics/AbcSize:
|
|
21
20
|
Metrics/ClassLength:
|
22
21
|
Max: 263
|
23
22
|
|
24
|
-
# Offense count:
|
23
|
+
# Offense count: 11
|
25
24
|
Metrics/CyclomaticComplexity:
|
26
25
|
Max: 11
|
27
26
|
|
28
|
-
# Offense count:
|
27
|
+
# Offense count: 29
|
29
28
|
# Configuration parameters: CountComments.
|
30
29
|
Metrics/MethodLength:
|
31
30
|
Max: 378
|
@@ -35,17 +34,44 @@ Metrics/MethodLength:
|
|
35
34
|
Metrics/ModuleLength:
|
36
35
|
Max: 380
|
37
36
|
|
38
|
-
# Offense count:
|
37
|
+
# Offense count: 11
|
39
38
|
Metrics/PerceivedComplexity:
|
40
39
|
Max: 15
|
41
40
|
|
41
|
+
# Offense count: 3
|
42
|
+
# Cop supports --auto-correct.
|
43
|
+
Performance/Casecmp:
|
44
|
+
Exclude:
|
45
|
+
- 'lib/mods_display/fields/contact.rb'
|
46
|
+
- 'lib/mods_display/fields/field.rb'
|
47
|
+
- 'lib/mods_display/fields/note.rb'
|
48
|
+
|
49
|
+
# Offense count: 4
|
50
|
+
# Cop supports --auto-correct.
|
51
|
+
# Configuration parameters: SingleLineConditionsOnly.
|
52
|
+
Style/ConditionalAssignment:
|
53
|
+
Exclude:
|
54
|
+
- 'lib/mods_display/fields/field.rb'
|
55
|
+
- 'lib/mods_display/fields/subject.rb'
|
56
|
+
|
42
57
|
# Offense count: 42
|
43
|
-
# Configuration parameters: Exclude.
|
44
58
|
Style/Documentation:
|
45
59
|
Enabled: false
|
46
60
|
|
61
|
+
# Offense count: 1
|
62
|
+
# Configuration parameters: MinBodyLength.
|
63
|
+
Style/GuardClause:
|
64
|
+
Exclude:
|
65
|
+
- 'lib/mods_display/fields/related_item.rb'
|
66
|
+
|
67
|
+
# Offense count: 1
|
68
|
+
Style/IfInsideElse:
|
69
|
+
Exclude:
|
70
|
+
- 'lib/mods_display/fields/subject.rb'
|
71
|
+
|
47
72
|
# Offense count: 8
|
48
73
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
74
|
+
# SupportedStyles: snake_case, camelCase
|
49
75
|
Style/MethodName:
|
50
76
|
Enabled: false
|
51
77
|
|
@@ -54,7 +80,36 @@ Style/MultilineBlockChain:
|
|
54
80
|
Exclude:
|
55
81
|
- 'lib/mods_display/fields/imprint.rb'
|
56
82
|
|
83
|
+
# Offense count: 1
|
84
|
+
# Cop supports --auto-correct.
|
85
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
|
86
|
+
# SupportedStyles: aligned, indented
|
87
|
+
Style/MultilineOperationIndentation:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
# Offense count: 1
|
91
|
+
# Cop supports --auto-correct.
|
92
|
+
Style/MutableConstant:
|
93
|
+
Exclude:
|
94
|
+
- 'lib/mods_display/version.rb'
|
95
|
+
|
96
|
+
# Offense count: 1
|
97
|
+
# Cop supports --auto-correct.
|
98
|
+
Style/RedundantSelf:
|
99
|
+
Exclude:
|
100
|
+
- 'lib/mods_display/fields/subject.rb'
|
101
|
+
|
57
102
|
# Offense count: 8
|
58
103
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
104
|
+
# SupportedStyles: snake_case, camelCase
|
59
105
|
Style/VariableName:
|
60
106
|
Enabled: false
|
107
|
+
|
108
|
+
# Offense count: 13
|
109
|
+
Style/ZeroLengthPredicate:
|
110
|
+
Exclude:
|
111
|
+
- 'lib/mods_display/fields/cartographics.rb'
|
112
|
+
- 'lib/mods_display/fields/collection.rb'
|
113
|
+
- 'lib/mods_display/fields/imprint.rb'
|
114
|
+
- 'lib/mods_display/fields/name.rb'
|
115
|
+
- 'lib/mods_display/fields/related_item.rb'
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -6,7 +6,11 @@ RuboCop::RakeTask.new
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
8
|
task :ci do
|
9
|
-
|
9
|
+
# Commenting out Rubocop as part of the CI build temporarily
|
10
|
+
# because TravisCI is not respecting the .rubocop_todo.yml
|
11
|
+
# You can and should still run rubocop in your editor or
|
12
|
+
# from the command line manually.
|
13
|
+
# Rake::Task['rubocop'].invoke
|
10
14
|
Rake::Task['spec'].invoke
|
11
15
|
end
|
12
16
|
|
data/config/locales/en.yml
CHANGED
@@ -21,9 +21,11 @@ en:
|
|
21
21
|
date_valid: "Date valid:"
|
22
22
|
digital_origin: "Digital origin:"
|
23
23
|
doi: "DOI:"
|
24
|
-
|
24
|
+
extent: "Extent:"
|
25
|
+
form: "Form:"
|
25
26
|
frequency: "Frequency:"
|
26
27
|
genre: "Genre:"
|
28
|
+
geo_extension: 'Format:'
|
27
29
|
handle: "Handle:"
|
28
30
|
identifier: "Identifier:"
|
29
31
|
imprint: "Imprint:"
|
data/lib/mods_display.rb
CHANGED
@@ -8,7 +8,6 @@ require 'mods_display/configuration'
|
|
8
8
|
require 'mods_display/configuration/base'
|
9
9
|
require 'mods_display/configuration/access_condition'
|
10
10
|
require 'mods_display/configuration/imprint'
|
11
|
-
require 'mods_display/configuration/format'
|
12
11
|
require 'mods_display/configuration/genre'
|
13
12
|
require 'mods_display/configuration/name'
|
14
13
|
require 'mods_display/configuration/note'
|
@@ -24,8 +23,10 @@ require 'mods_display/fields/contact'
|
|
24
23
|
require 'mods_display/fields/contents'
|
25
24
|
require 'mods_display/fields/cartographics'
|
26
25
|
require 'mods_display/fields/description'
|
27
|
-
require 'mods_display/fields/
|
26
|
+
require 'mods_display/fields/extent'
|
27
|
+
require 'mods_display/fields/form'
|
28
28
|
require 'mods_display/fields/genre'
|
29
|
+
require 'mods_display/fields/geo'
|
29
30
|
require 'mods_display/fields/identifier'
|
30
31
|
require 'mods_display/fields/imprint'
|
31
32
|
require 'mods_display/fields/language'
|
@@ -26,10 +26,6 @@ module ModsDisplay
|
|
26
26
|
@genre ||= ModsDisplay::Configuration::Genre.new(&genre || proc {})
|
27
27
|
end
|
28
28
|
|
29
|
-
def format(&format)
|
30
|
-
@format ||= ModsDisplay::Configuration::Format.new(&format || proc {})
|
31
|
-
end
|
32
|
-
|
33
29
|
def imprint(&imprint)
|
34
30
|
@imprint ||= ModsDisplay::Configuration::Imprint.new(&imprint || proc {})
|
35
31
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ModsDisplay
|
2
|
+
class Extent < Field
|
3
|
+
def fields
|
4
|
+
return [] unless extent_fields.present?
|
5
|
+
[
|
6
|
+
ModsDisplay::Values.new(
|
7
|
+
label: I18n.t('mods_display.extent'),
|
8
|
+
values: extent_fields.map(&:text)
|
9
|
+
)
|
10
|
+
]
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def extent_fields
|
16
|
+
@values.map(&:extent)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ModsDisplay
|
2
|
+
class Form < Field
|
3
|
+
def fields
|
4
|
+
return [] unless form_fields.present?
|
5
|
+
[
|
6
|
+
ModsDisplay::Values.new(
|
7
|
+
label: I18n.t('mods_display.form'),
|
8
|
+
values: form_fields.map(&:text)
|
9
|
+
)
|
10
|
+
]
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def form_fields
|
16
|
+
@values.map(&:form)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ModsDisplay
|
2
|
+
class Geo < Field
|
3
|
+
def fields
|
4
|
+
return [] unless geo_extensions.present?
|
5
|
+
extensions = geo_extensions.map(&method(:process_geo_extension))
|
6
|
+
[
|
7
|
+
ModsDisplay::Values.new(
|
8
|
+
label: I18n.t('mods_display.geo_extension'),
|
9
|
+
values: extensions
|
10
|
+
)
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def process_geo_extension(extension)
|
17
|
+
rdf = Nokogiri::XML(extension.children.to_s)
|
18
|
+
[
|
19
|
+
rdf.xpath('//format').text[/format=(.*)$/, 1],
|
20
|
+
rdf.xpath('//type').text[/#(.*)$/, 1]
|
21
|
+
].compact.join('; ')
|
22
|
+
end
|
23
|
+
|
24
|
+
def geo_extensions
|
25
|
+
@geo_values ||= @values.select do |value|
|
26
|
+
displayLabel(value) =~ /^geo:?$/
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/mods_display/html.rb
CHANGED
@@ -78,7 +78,9 @@ module ModsDisplay
|
|
78
78
|
:imprint,
|
79
79
|
:resourceType,
|
80
80
|
:genre,
|
81
|
-
:
|
81
|
+
:form,
|
82
|
+
:extent,
|
83
|
+
:geo,
|
82
84
|
:description,
|
83
85
|
:cartographics,
|
84
86
|
:abstract,
|
@@ -101,7 +103,9 @@ module ModsDisplay
|
|
101
103
|
name: :plain_name,
|
102
104
|
resourceType: :typeOfResource,
|
103
105
|
genre: :genre,
|
104
|
-
|
106
|
+
form: :physical_description,
|
107
|
+
extent: :physical_description,
|
108
|
+
geo: :extension,
|
105
109
|
imprint: :origin_info,
|
106
110
|
language: :language,
|
107
111
|
description: :physical_description,
|
data/lib/mods_display/version.rb
CHANGED
data/mods_display.gemspec
CHANGED
@@ -17,7 +17,8 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(spec)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
|
20
|
+
# Need to pin to < 1.2.0 because stanford-mods 13e5f23 breaks location
|
21
|
+
gem.add_dependency 'stanford-mods', '< 1.2.0'
|
21
22
|
gem.add_dependency 'i18n'
|
22
23
|
|
23
24
|
gem.add_development_dependency 'rake'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ModsDisplay::Extent do
|
4
|
+
let(:mods) do
|
5
|
+
<<-XML
|
6
|
+
<mods>
|
7
|
+
<physicalDescription>
|
8
|
+
<extent>Extent Value</extent>
|
9
|
+
</physicalDescription>
|
10
|
+
</mods>
|
11
|
+
XML
|
12
|
+
end
|
13
|
+
|
14
|
+
subject do
|
15
|
+
parsed_mods = Stanford::Mods::Record.new.from_str(mods, false).physical_description
|
16
|
+
described_class.new(parsed_mods, ModsDisplay::Configuration::Base.new, double('controller')).fields
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'label' do
|
20
|
+
it 'is "Extent"' do
|
21
|
+
expect(subject.first.label).to eq 'Extent:'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'values' do
|
26
|
+
it 'returns the text of the extent element' do
|
27
|
+
expect(subject.first.values).to eq ['Extent Value']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ModsDisplay::Form do
|
4
|
+
let(:mods) do
|
5
|
+
<<-XML
|
6
|
+
<mods>
|
7
|
+
<physicalDescription>
|
8
|
+
<form>Form Value</form>
|
9
|
+
</physicalDescription>
|
10
|
+
</mods>
|
11
|
+
XML
|
12
|
+
end
|
13
|
+
|
14
|
+
subject do
|
15
|
+
parsed_mods = Stanford::Mods::Record.new.from_str(mods, false).physical_description
|
16
|
+
described_class.new(parsed_mods, ModsDisplay::Configuration::Base.new, double('controller')).fields
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'label' do
|
20
|
+
it 'is "Form"' do
|
21
|
+
expect(subject.first.label).to eq 'Form:'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'values' do
|
26
|
+
it 'returns the text of the form element' do
|
27
|
+
expect(subject.first.values).to eq ['Form Value']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
def mods_display_geo(mods_record)
|
4
|
+
ModsDisplay::Geo.new(mods_record, ModsDisplay::Configuration::Base.new, double('controller'))
|
5
|
+
end
|
6
|
+
|
7
|
+
describe ModsDisplay::Geo do
|
8
|
+
let(:mods) do
|
9
|
+
<<-XML
|
10
|
+
<mods>
|
11
|
+
<extension displayLabel="geo">
|
12
|
+
<rdf:RDF xmlns:gml="http://www.opengis.net/gml/3.2/" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
13
|
+
<rdf:Description>
|
14
|
+
<dc:format>image/tiff; format=ArcGRID</dc:format>
|
15
|
+
<dc:type>Dataset#Raster</dc:type>
|
16
|
+
</rdf:Description>
|
17
|
+
</rdf:RDF>
|
18
|
+
</extension>
|
19
|
+
</mods>
|
20
|
+
XML
|
21
|
+
end
|
22
|
+
|
23
|
+
subject do
|
24
|
+
mods_display_geo(Stanford::Mods::Record.new.from_str(mods, false).extension).fields
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'labels' do
|
28
|
+
it 'is Format' do
|
29
|
+
expect(subject.length).to eq(1)
|
30
|
+
expect(subject.first.label).to eq('Format:')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'fields' do
|
35
|
+
it 'joins the normalized format and type with a semicolon' do
|
36
|
+
expect(subject.length).to eq(1)
|
37
|
+
expect(subject.first.values).to eq(['ArcGRID; Raster'])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,58 +1,79 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
describe ModsDisplay::Location do
|
4
|
+
let(:location_mods) do
|
5
|
+
<<-XML
|
6
|
+
<mods>
|
7
|
+
<location>
|
8
|
+
<shelfLocation>On Shelf A</shelfLocation>
|
9
|
+
</location>
|
10
|
+
</mods>
|
11
|
+
XML
|
12
|
+
end
|
6
13
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
'<mods><location><physicalLocation>The Location</physicalLocation></location></mods>', false
|
11
|
-
).location
|
12
|
-
@urls = Stanford::Mods::Record.new.from_str(
|
13
|
-
"<mods>
|
14
|
+
let(:url_mods) do
|
15
|
+
<<-XML
|
16
|
+
<mods>
|
14
17
|
<location>
|
15
18
|
<url displayLabel='Stanford University Library'>http://library.stanford.edu</url>
|
16
19
|
</location>
|
17
20
|
<location displayLabel='PURL'>
|
18
21
|
<url>http://purl.stanford.edu</url>
|
19
22
|
</location>
|
20
|
-
</mods>
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
</mods>
|
24
|
+
XML
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:repository_mods) do
|
28
|
+
<<-XML
|
29
|
+
<mods>
|
30
|
+
<location>
|
31
|
+
<physicalLocation type='repository'>Location Field</physicalLocation>
|
32
|
+
</location>
|
33
|
+
</mods>
|
34
|
+
XML
|
35
|
+
end
|
36
|
+
|
37
|
+
let(:location) do
|
38
|
+
mods = Stanford::Mods::Record.new.from_str(location_mods, false).location
|
39
|
+
described_class.new(mods, ModsDisplay::Configuration::Base.new, double('controller')).fields
|
29
40
|
end
|
41
|
+
|
42
|
+
let(:urls) do
|
43
|
+
mods = Stanford::Mods::Record.new.from_str(url_mods, false).location
|
44
|
+
described_class.new(mods, ModsDisplay::Configuration::Base.new, double('controller')).fields
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:repository_label) do
|
48
|
+
mods = Stanford::Mods::Record.new.from_str(repository_mods, false).location
|
49
|
+
described_class.new(mods, ModsDisplay::Configuration::Base.new, double('controller')).fields
|
50
|
+
end
|
51
|
+
|
30
52
|
describe 'label' do
|
31
53
|
it 'should have a default label' do
|
32
|
-
expect(
|
33
|
-
end
|
34
|
-
it 'should use the displayLabel attribute when one is available' do
|
35
|
-
expect(mods_display_location(@display_label).fields.first.label).to eq('Special Label:')
|
54
|
+
expect(location.first.label).to eq 'Location:'
|
36
55
|
end
|
56
|
+
|
37
57
|
it 'should handle the URL labels correctly' do
|
38
|
-
expect(
|
58
|
+
expect(urls.map(&:label)).to eq ['Location:', 'PURL:']
|
39
59
|
end
|
60
|
+
|
40
61
|
it 'should use get a label from a list of translations' do
|
41
|
-
expect(
|
62
|
+
expect(repository_label.first.label).to eq 'Repository:'
|
42
63
|
end
|
43
64
|
end
|
65
|
+
|
44
66
|
describe 'fields' do
|
45
67
|
describe 'URLs' do
|
46
68
|
it 'should link and use the displayLabel as text' do
|
47
|
-
|
48
|
-
|
49
|
-
field = fields.find { |f| f.label == 'Location:' }
|
69
|
+
expect(urls.length).to eq(2)
|
70
|
+
field = urls.find { |f| f.label == 'Location:' }
|
50
71
|
expect(field.values).to eq(["<a href='http://library.stanford.edu'>Stanford University Library</a>"])
|
51
72
|
end
|
73
|
+
|
52
74
|
it 'should link the URL itself in the absence of a displayLabel on the url element' do
|
53
|
-
|
54
|
-
|
55
|
-
field = fields.find { |f| f.label == 'PURL:' }
|
75
|
+
expect(urls.length).to eq(2)
|
76
|
+
field = urls.find { |f| f.label == 'PURL:' }
|
56
77
|
expect(field.values).to eq(["<a href='http://purl.stanford.edu'>http://purl.stanford.edu</a>"])
|
57
78
|
end
|
58
79
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mods_display
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jessie Keck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stanford-mods
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: i18n
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,7 +100,6 @@ files:
|
|
100
100
|
- lib/mods_display/configuration.rb
|
101
101
|
- lib/mods_display/configuration/access_condition.rb
|
102
102
|
- lib/mods_display/configuration/base.rb
|
103
|
-
- lib/mods_display/configuration/format.rb
|
104
103
|
- lib/mods_display/configuration/genre.rb
|
105
104
|
- lib/mods_display/configuration/imprint.rb
|
106
105
|
- lib/mods_display/configuration/name.rb
|
@@ -118,9 +117,11 @@ files:
|
|
118
117
|
- lib/mods_display/fields/contact.rb
|
119
118
|
- lib/mods_display/fields/contents.rb
|
120
119
|
- lib/mods_display/fields/description.rb
|
120
|
+
- lib/mods_display/fields/extent.rb
|
121
121
|
- lib/mods_display/fields/field.rb
|
122
|
-
- lib/mods_display/fields/
|
122
|
+
- lib/mods_display/fields/form.rb
|
123
123
|
- lib/mods_display/fields/genre.rb
|
124
|
+
- lib/mods_display/fields/geo.rb
|
124
125
|
- lib/mods_display/fields/identifier.rb
|
125
126
|
- lib/mods_display/fields/imprint.rb
|
126
127
|
- lib/mods_display/fields/language.rb
|
@@ -148,8 +149,10 @@ files:
|
|
148
149
|
- spec/fields/contact_spec.rb
|
149
150
|
- spec/fields/contents_spec.rb
|
150
151
|
- spec/fields/description_spec.rb
|
151
|
-
- spec/fields/
|
152
|
+
- spec/fields/extent_spec.rb
|
153
|
+
- spec/fields/form_spec.rb
|
152
154
|
- spec/fields/genre_spec.rb
|
155
|
+
- spec/fields/geo_spec.rb
|
153
156
|
- spec/fields/identifier_spec.rb
|
154
157
|
- spec/fields/imprint_spec.rb
|
155
158
|
- spec/fields/language_spec.rb
|
@@ -209,8 +212,10 @@ test_files:
|
|
209
212
|
- spec/fields/contact_spec.rb
|
210
213
|
- spec/fields/contents_spec.rb
|
211
214
|
- spec/fields/description_spec.rb
|
212
|
-
- spec/fields/
|
215
|
+
- spec/fields/extent_spec.rb
|
216
|
+
- spec/fields/form_spec.rb
|
213
217
|
- spec/fields/genre_spec.rb
|
218
|
+
- spec/fields/geo_spec.rb
|
214
219
|
- spec/fields/identifier_spec.rb
|
215
220
|
- spec/fields/imprint_spec.rb
|
216
221
|
- spec/fields/language_spec.rb
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module ModsDisplay
|
2
|
-
class Format < Field
|
3
|
-
def fields
|
4
|
-
return_fields = []
|
5
|
-
if @values.respond_to?(:format) &&
|
6
|
-
!@values.format.nil? &&
|
7
|
-
!@values.format.empty?
|
8
|
-
return_fields << ModsDisplay::Values.new(label: format_label,
|
9
|
-
values: [decorate_formats(@values.format).join(', ')])
|
10
|
-
end
|
11
|
-
unless @values.physical_description.nil?
|
12
|
-
@values.physical_description.each do |description|
|
13
|
-
unless description.form.nil? || description.form.empty?
|
14
|
-
return_fields << ModsDisplay::Values.new(
|
15
|
-
label: displayLabel(description) || format_label,
|
16
|
-
values: [description.form.map { |f| f.text.strip }.uniq.join(', ')]
|
17
|
-
)
|
18
|
-
end
|
19
|
-
unless description.extent.nil? || description.extent.empty?
|
20
|
-
return_fields << ModsDisplay::Values.new(label: displayLabel(description) || format_label,
|
21
|
-
values: [description.extent.map(&:text).join(', ')])
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
collapse_fields(return_fields)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def decorate_formats(formats)
|
31
|
-
formats.map do |format|
|
32
|
-
"<span data-mods-display-format='#{self.class.format_class(format)}'>#{format}</span>"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.format_class(format)
|
37
|
-
return format if format.nil?
|
38
|
-
format.strip.downcase.gsub(%r{/|\\|\s+}, '_')
|
39
|
-
end
|
40
|
-
|
41
|
-
def format_label
|
42
|
-
I18n.t('mods_display.format')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/spec/fields/format_spec.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
def mods_display_format(mods)
|
3
|
-
ModsDisplay::Format.new(mods, ModsDisplay::Configuration::Base.new, double('controller'))
|
4
|
-
end
|
5
|
-
|
6
|
-
describe ModsDisplay::Format do
|
7
|
-
before(:all) do
|
8
|
-
@format = Stanford::Mods::Record.new.from_str(
|
9
|
-
'<mods><typeOfResource>Format</typeOfResource></mods>', false
|
10
|
-
).typeOfResource
|
11
|
-
@duplicate_forms = Stanford::Mods::Record.new.from_str(
|
12
|
-
'<mods><physicalDescription><form>Map</form><form>Map</form></physicalDescription></mods>', false
|
13
|
-
)
|
14
|
-
@display_label = Stanford::Mods::Record.new.from_str(
|
15
|
-
"<mods><typeOfResource displayLabel='SpecialFormat'>Mixed Materials</typeOfResource></mods>", false
|
16
|
-
).typeOfResource
|
17
|
-
@space_format = Stanford::Mods::Record.new.from_str(
|
18
|
-
'<mods><typeOfResource>Mixed Materials</typeOfResource></mods>', false
|
19
|
-
).typeOfResource
|
20
|
-
@slash_format = Stanford::Mods::Record.new.from_str(
|
21
|
-
'<mods><typeOfResource>Manuscript/Archive</typeOfResource></mods>', false
|
22
|
-
).typeOfResource
|
23
|
-
end
|
24
|
-
describe 'format_class' do
|
25
|
-
it 'should remove any spaces' do
|
26
|
-
expect(ModsDisplay::Format.send(:format_class, 'Mixed Materials')).to eq('mixed_materials')
|
27
|
-
end
|
28
|
-
it 'should replace any slashes' do
|
29
|
-
expect(ModsDisplay::Format.send(:format_class, 'Manuscript/Archive')).to eq('manuscript_archive')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
describe 'fields' do
|
33
|
-
describe 'form' do
|
34
|
-
it 'should remove duplicate values' do
|
35
|
-
fields = mods_display_format(@duplicate_forms).fields
|
36
|
-
expect(fields.length).to eq(1)
|
37
|
-
expect(fields.first.values).to eq(['Map'])
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|