mods_display 0.5.1 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 53261106f9194d4a55bfa879bed5de2456ec8cda
4
- data.tar.gz: a337bd0562de9d50a6361f571bdc87ff48809b38
2
+ SHA256:
3
+ metadata.gz: c2d5c102f64b65d4313c4aad186328f17edf6475908f360762591ec4ded1f044
4
+ data.tar.gz: fefe5bd0aa2a29fe4cb60ad94e40840a3a1fe4a12b30ffccfc08b32361d04a5b
5
5
  SHA512:
6
- metadata.gz: a41f34b9565c81f5ab3ce15c08e43bdedf5793021cef6e6f65526c13174f798288b0636ff8ce0332fbcfd5b69137caa2e3a015b6ba61e9417b62ced3d618e171
7
- data.tar.gz: adaccbdda2e72b8eebadf19b18d1628c799efa300d63c0813dfc9112c1656eee3f583acd2309619dc1fbe97f0c90ee153e4898cab2cbf700bbb6dcc04a5a2eeb
6
+ metadata.gz: 5230f9bda246de22ebaaab5d01f3dc8a6d02f7a92f56a6caa1aa8e7d39039d8cb2d2fd8f39e8797d0757fb49dea269e680191ba9d495ae45ddf20cdfbfb3ae55
7
+ data.tar.gz: 5d5144f39760608dcb3a628022d1e8335e54b23a0c6e2b172c7705c68bd1a2fc12fa8b3155635c77bae9c74842bb3aeefc61639ea3c717f0495df7860faf6853
data/.travis.yml CHANGED
@@ -3,4 +3,3 @@ notifications:
3
3
  rvm:
4
4
  - 2.4.1
5
5
  - 2.3.4
6
- - 2.2.8
data/Gemfile CHANGED
@@ -3,5 +3,3 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in mods_display.gemspec
4
4
  gemspec
5
5
 
6
- # Pin to activesupport 4.x for older versions of ruby
7
- gem 'activesupport', '~> 4.2' if RUBY_VERSION < '2.2.2'
@@ -13,7 +13,7 @@ module ModsDisplay
13
13
  private
14
14
 
15
15
  def extent_fields
16
- @values.map(&:extent)
16
+ @values.map(&:extent).flatten
17
17
  end
18
18
  end
19
19
  end
@@ -5,7 +5,7 @@ module ModsDisplay
5
5
  [
6
6
  ModsDisplay::Values.new(
7
7
  label: I18n.t('mods_display.form'),
8
- values: form_fields.map(&:text)
8
+ values: form_fields.map(&:text).uniq { |x| x.downcase.gsub(/\s/, '').gsub(/[[:punct:]]/, '') }
9
9
  )
10
10
  ]
11
11
  end
@@ -13,7 +13,7 @@ module ModsDisplay
13
13
  private
14
14
 
15
15
  def form_fields
16
- @values.map(&:form)
16
+ @values.map(&:form).flatten
17
17
  end
18
18
  end
19
19
  end
@@ -40,7 +40,7 @@ module ModsDisplay
40
40
  def method_missing(method_name, *args, &block)
41
41
  if to_s.respond_to?(method_name)
42
42
  to_html.send(method_name, *args, &block)
43
- elsif mods_display_fields.include?(method_name)
43
+ elsif method_name == :subTitle || mods_display_fields.include?(method_name)
44
44
  mods_field(@xml, method_name).fields
45
45
  else
46
46
  super
@@ -1,3 +1,3 @@
1
1
  module ModsDisplay
2
- VERSION = '0.5.1'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -6,6 +6,7 @@ describe ModsDisplay::Extent do
6
6
  <mods>
7
7
  <physicalDescription>
8
8
  <extent>Extent Value</extent>
9
+ <extent>Extent Value 2</extent>
9
10
  </physicalDescription>
10
11
  </mods>
11
12
  XML
@@ -24,7 +25,7 @@ describe ModsDisplay::Extent do
24
25
 
25
26
  describe 'values' do
26
27
  it 'returns the text of the extent element' do
27
- expect(subject.first.values).to eq ['Extent Value']
28
+ expect(subject.first.values).to eq ['Extent Value', 'Extent Value 2']
28
29
  end
29
30
  end
30
31
  end
@@ -6,6 +6,7 @@ describe ModsDisplay::Form do
6
6
  <mods>
7
7
  <physicalDescription>
8
8
  <form>Form Value</form>
9
+ <form>Form Value 2</form>
9
10
  </physicalDescription>
10
11
  </mods>
11
12
  XML
@@ -24,7 +25,25 @@ describe ModsDisplay::Form do
24
25
 
25
26
  describe 'values' do
26
27
  it 'returns the text of the form element' do
27
- expect(subject.first.values).to eq ['Form Value']
28
+ expect(subject.first.values).to eq ['Form Value', 'Form Value 2']
29
+ end
30
+
31
+ context 'duplicated data' do
32
+ let(:mods) do
33
+ <<-XML
34
+ <mods>
35
+ <physicalDescription>
36
+ <form authority="gmd">electronic resource.</form>
37
+ <form authority="zxy">electronicresource!</form>
38
+ <form authority="marccategory">electronic Resource</form>
39
+ </physicalDescription>
40
+ </mods>
41
+ XML
42
+ end
43
+
44
+ it 'uses only unique form values, ignore differences in case, punctuation or whitespace' do
45
+ expect(subject.first.values).to match_array ['electronic resource.']
46
+ end
28
47
  end
29
48
  end
30
49
  end
@@ -5,6 +5,7 @@ def html_from_mods(xml, locale = nil)
5
5
  model = TestModel.new
6
6
  model.modsxml = xml
7
7
  I18n.locale = locale if locale
8
+ I18n.fallbacks[:fr] = [:fr, :en]
8
9
  TestController.new.render_mods_display(model)
9
10
  end
10
11
 
@@ -53,6 +54,14 @@ describe 'HTML Output' do
53
54
  expect(@multiple_titles.body).not_to include('<dd>Main Title</dd>')
54
55
  expect(@multiple_titles.body).to include('<dd>Alternate Title</dd>')
55
56
  end
57
+
58
+ it 'should allow access to the subTitle independently from the title (for use with #body or fields)' do
59
+ sub_title = @multiple_titles.subTitle
60
+ expect(sub_title.length).to eq 1
61
+ expect(sub_title.first).to be_a ModsDisplay::Values
62
+ expect(sub_title.first.label).to match(/^Alternative title/i)
63
+ expect(sub_title.first.values).to eq(['Alternate Title'])
64
+ end
56
65
  end
57
66
  describe 'individual fields' do
58
67
  it 'should return ModsDispaly::Values for the specefied field' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mods_display
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.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: 2017-12-07 00:00:00.000000000 Z
11
+ date: 2018-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stanford-mods
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
227
  version: '0'
228
228
  requirements: []
229
229
  rubyforge_project:
230
- rubygems_version: 2.6.11
230
+ rubygems_version: 2.7.6
231
231
  signing_key:
232
232
  specification_version: 4
233
233
  summary: The MODS Display gem allows implementers to configure a customized display