mods 2.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +24 -0
- data/.gitignore +1 -0
- data/Gemfile +0 -4
- data/README.md +1 -3
- data/lib/mods/date.rb +51 -17
- data/lib/mods/marc_country_codes.rb +12 -10
- data/lib/mods/nom_terminology.rb +110 -849
- data/lib/mods/reader.rb +9 -39
- data/lib/mods/record.rb +13 -28
- data/lib/mods/version.rb +1 -1
- data/mods.gemspec +3 -3
- data/spec/fixture_data/hp566jq8781.xml +334 -0
- data/spec/integration/parker_spec.rb +217 -0
- data/spec/{date_spec.rb → lib/date_spec.rb} +8 -1
- data/spec/lib/language_spec.rb +123 -0
- data/spec/lib/location_spec.rb +175 -0
- data/spec/lib/name_spec.rb +368 -0
- data/spec/lib/origin_info_spec.rb +134 -0
- data/spec/lib/part_spec.rb +162 -0
- data/spec/lib/physical_description_spec.rb +72 -0
- data/spec/{reader_spec.rb → lib/reader_spec.rb} +1 -41
- data/spec/lib/record_info_spec.rb +114 -0
- data/spec/lib/record_spec.rb +287 -0
- data/spec/lib/related_item_spec.rb +124 -0
- data/spec/lib/subject_spec.rb +427 -0
- data/spec/lib/title_spec.rb +108 -0
- data/spec/lib/top_level_elmnts_simple_spec.rb +169 -0
- data/spec/spec_helper.rb +87 -6
- data/spec/support/fixtures.rb +9 -0
- metadata +61 -43
- data/.coveralls.yml +0 -1
- data/.travis.yml +0 -6
- data/spec/language_spec.rb +0 -118
- data/spec/location_spec.rb +0 -295
- data/spec/name_spec.rb +0 -759
- data/spec/origin_info_spec.rb +0 -447
- data/spec/part_spec.rb +0 -471
- data/spec/physical_description_spec.rb +0 -144
- data/spec/record_info_spec.rb +0 -493
- data/spec/record_spec.rb +0 -356
- data/spec/related_item_spec.rb +0 -305
- data/spec/subject_spec.rb +0 -809
- data/spec/title_spec.rb +0 -226
- data/spec/top_level_elmnts_simple_spec.rb +0 -369
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Mods Top Level Elements that do not have Child Elements" do
|
4
|
+
it "should get the text contents of any single simple (cannot have child elements) top level element" do
|
5
|
+
Mods::TOP_LEVEL_ELEMENTS_SIMPLE.each { |elname|
|
6
|
+
record = mods_record("<#{elname}>hi</#{elname}>")
|
7
|
+
expect(record.send(elname.to_sym).map { |e| e.text }).to eq(["hi"])
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return an array of strings when there are multiple occurrences of simple top level elements" do
|
12
|
+
expect(mods_record('<note>hi</note><note>hello</note></mods>').note.map { |e| e.text }).to eq(%w[hi hello])
|
13
|
+
end
|
14
|
+
|
15
|
+
context "<abstract> child element" do
|
16
|
+
it ".abstract.displayLabel should be an accessor for displayLabel attribute on abstract element: <abstract displayLabel='foo'>" do
|
17
|
+
record = mods_record('<abstract displayLabel="Summary">blah blah blah</abstract>')
|
18
|
+
expect(record.abstract.displayLabel).to eq(['Summary'])
|
19
|
+
end
|
20
|
+
it ".abstract.type_at should be an accessor for type attribute on abstract element: <abstract type='foo'>" do
|
21
|
+
record = mods_record('<abstract type="Scope and Contents note">blah blah blah</abstract>')
|
22
|
+
expect(record.abstract.type_at).to eq(['Scope and Contents note'])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "<accessCondition> child element" do
|
27
|
+
before(:all) do
|
28
|
+
@acc_cond = mods_record('<accessCondition displayLabel="meh" type="useAndReproduction">blah blah blah</accessCondition></mods>').accessCondition
|
29
|
+
@acc_cond2 = mods_record('<accessCondition type="useAndReproduction">All rights reserved.</accessCondition></mods>').accessCondition
|
30
|
+
end
|
31
|
+
it ".accessCondition.displayLabel should be an accessor for displayLabel attribute on accessCondition element: <accessCondition displayLabel='foo'>" do
|
32
|
+
expect(@acc_cond.displayLabel).to eq(['meh'])
|
33
|
+
end
|
34
|
+
it ".accessCondition.type_at should be an accessor for type attribute on accessCondition element: <accessCondition type='foo'>" do
|
35
|
+
[@acc_cond, @acc_cond2].each { |ac| expect(ac.type_at).to eq(['useAndReproduction']) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "<classification> child element" do
|
40
|
+
before(:all) do
|
41
|
+
@class1 = mods_record('<classification authority="ddc" edition="11">683</classification></mods>').classification
|
42
|
+
@class2 = mods_record('<classification authority="lcc">JK609.M2</classification></mods>').classification
|
43
|
+
end
|
44
|
+
it ".classification.authority should be an accessor for authority attribute on classification element: <classification authority='foo'>" do
|
45
|
+
expect(@class1.authority).to eq(['ddc'])
|
46
|
+
expect(@class2.authority).to eq(['lcc'])
|
47
|
+
end
|
48
|
+
it ".classification.edition should be an accessor for edition attribute on classification element: <classification edition='foo'>" do
|
49
|
+
expect(@class1.edition).to eq(['11'])
|
50
|
+
end
|
51
|
+
it "should recognize all authority attributes" do
|
52
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
53
|
+
record = mods_record("<classification #{a}='attr_val'>zzz</classification>")
|
54
|
+
expect(record.classification.send(a.to_sym)).to eq(['attr_val'])
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "<extension> child element" do
|
60
|
+
before(:all) do
|
61
|
+
@ext = record = mods_record('<extension xmlns:dcterms="http://purl.org/dc/ >
|
62
|
+
<dcterms:modified>2003-03-24</dcterms:modified>
|
63
|
+
</extension></mods>').extension
|
64
|
+
end
|
65
|
+
it ".extension.displayLabel should be an accessor for displayLabel attribute on extension element: <extension displayLabel='foo'>" do
|
66
|
+
record = mods_record('<extension displayLabel="something">blah blah blah</extension>')
|
67
|
+
expect(record.extension.displayLabel).to eq(['something'])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "<genre> child element" do
|
72
|
+
it ".genre.displayLabel should be an accessor for displayLabel attribute on genre element: <genre displayLabel='foo'>" do
|
73
|
+
record = mods_record('<genre displayLabel="something">blah blah blah</genre>')
|
74
|
+
expect(record.genre.displayLabel).to eq(['something'])
|
75
|
+
end
|
76
|
+
it ".genre.type_at should be an accessor for type attribute on genre element: <genre type='foo'>" do
|
77
|
+
record = mods_record('<genre type="maybe">blah blah blah</genre>')
|
78
|
+
expect(record.genre.type_at).to eq(['maybe'])
|
79
|
+
end
|
80
|
+
it ".genre.usage should be an accessor for usage attribute on genre element: <genre usage='foo'>" do
|
81
|
+
record = mods_record('<genre usage="fer sure">blah blah blah</genre>')
|
82
|
+
expect(record.genre.usage).to eq(['fer sure'])
|
83
|
+
end
|
84
|
+
it "should recognize all authority attributes" do
|
85
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
86
|
+
record = mods_record("<genre #{a}='attr_val'>zzz</genre>")
|
87
|
+
expect(record.genre.send(a.to_sym)).to eq(['attr_val'])
|
88
|
+
}
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "<identifier> child element" do
|
93
|
+
let(:record) do
|
94
|
+
mods_record('<identifier displayLabel="book_number" type="local">70</identifier></mods>')
|
95
|
+
end
|
96
|
+
it ".identifier.displayLabel should be an accessor for displayLabel attribute on identifier element: <identifier displayLabel='foo'>" do
|
97
|
+
expect(record.identifier.displayLabel).to eq(['book_number'])
|
98
|
+
end
|
99
|
+
it ".identifier.invalid should be an accessor for invalid attribute on identifier element: <identifier invalid='foo'>" do
|
100
|
+
record = mods_record('<identifier type="isbn" invalid="yes">0877780116</identifier>')
|
101
|
+
expect(record.identifier.invalid).to eq(['yes'])
|
102
|
+
end
|
103
|
+
it ".identifier.type_at should be an accessor for type attribute on identifier element: <identifier type='foo'>" do
|
104
|
+
expect(record.identifier.type_at).to eq(['local'])
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context "<note> child element" do
|
109
|
+
it ".note.displayLabel should be an accessor for displayLabel attribute on note element: <note displayLabel='foo'>" do
|
110
|
+
record = mods_record('<note displayLabel="state_note">blah</note>')
|
111
|
+
expect(record.note.displayLabel).to eq(['state_note'])
|
112
|
+
end
|
113
|
+
it ".note.id_at should be an accessor for ID attribute on note element: <note ID='foo'>" do
|
114
|
+
record = mods_record('<note ID="foo">blah blah blah</note>')
|
115
|
+
expect(record.note.id_at).to eq(['foo'])
|
116
|
+
end
|
117
|
+
it ".note.type_at should be an accessor for type attribute on note element: <note type='foo'>" do
|
118
|
+
record = mods_record('<note type="content">blah</note>')
|
119
|
+
expect(record.note.type_at).to eq(['content'])
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "<tableOfContents> child element" do
|
124
|
+
it ".tableOfContents.displayLabel should be an accessor for displayLabel attribute on tableOfContents element: <tableOfContents displayLabel='foo'>" do
|
125
|
+
record = mods_record('<tableOfContents displayLabel="Chapters included in book">blah blah</tableOfContents>')
|
126
|
+
expect(record.tableOfContents.displayLabel).to eq(['Chapters included in book'])
|
127
|
+
end
|
128
|
+
it ".tableOfContents.shareable should be an accessor for shareable attribute on tableOfContents element: <tableOfContents shareable='foo'>" do
|
129
|
+
record = mods_record('<tableOfContents shareable="no">blah blah blah</tableOfContents>')
|
130
|
+
expect(record.tableOfContents.shareable).to eq(['no'])
|
131
|
+
end
|
132
|
+
it ".tableOfContents.type_at should be an accessor for type attribute on tableOfContents element: <tableOfContents type='foo'>" do
|
133
|
+
record = mods_record('<tableOfContents type="partial contents">blah blah</tableOfContents>')
|
134
|
+
expect(record.tableOfContents.type_at).to eq(['partial contents'])
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context "<targetAudience> child element" do
|
139
|
+
it ".targetAudience.displayLabel should be an accessor for displayLabel attribute on targetAudience element: <targetAudience displayLabel='foo'>" do
|
140
|
+
record = mods_record('<targetAudience displayLabel="ta da">blah blah</targetAudience>')
|
141
|
+
expect(record.targetAudience.displayLabel).to eq(['ta da'])
|
142
|
+
end
|
143
|
+
it "should recognize all authority attributes" do
|
144
|
+
Mods::AUTHORITY_ATTRIBS.each { |a|
|
145
|
+
record = mods_record("<targetAudience #{a}='attr_val'>zzz</targetAudience>")
|
146
|
+
expect(record.targetAudience.send(a.to_sym)).to eq(['attr_val'])
|
147
|
+
}
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
context "<typeOfResource> child element" do
|
152
|
+
it ".typeOfResource.collection should be an accessor for collection attribute on typeOfResource element: <typeOfResource collection='foo'>" do
|
153
|
+
record = mods_record('<typeOfResource collection="yes">blah blah blah</typeOfResource>')
|
154
|
+
expect(record.typeOfResource.collection).to eq(['yes'])
|
155
|
+
end
|
156
|
+
it ".typeOfResource.displayLabel should be an accessor for displayLabel attribute on typeOfResource element: <typeOfResource displayLabel='foo'>" do
|
157
|
+
record = mods_record('<typeOfResource displayLabel="Summary">blah blah blah</typeOfResource>')
|
158
|
+
expect(record.typeOfResource.displayLabel).to eq(['Summary'])
|
159
|
+
end
|
160
|
+
it ".typeOfResource.manuscript should be an accessor for manuscript attribute on typeOfResource element: <typeOfResource manuscript='foo'>" do
|
161
|
+
record = mods_record('<typeOfResource manuscript="yes">blah blah blah</typeOfResource>')
|
162
|
+
expect(record.typeOfResource.manuscript).to eq(['yes'])
|
163
|
+
end
|
164
|
+
it ".typeOfResource.usage should be an accessor for usage attribute on typeOfResource element: <typeOfResource usage='foo'>" do
|
165
|
+
record = mods_record('<typeOfResource usage="fer sure">blah blah blah</typeOfResource>')
|
166
|
+
expect(record.typeOfResource.usage).to eq(['fer sure'])
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,91 @@
|
|
1
|
-
|
2
|
-
Coveralls.wear!
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
6
5
|
|
7
6
|
require 'mods'
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].sort.each { |f| require f }
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include Fixtures
|
12
|
+
|
13
|
+
# rspec-expectations config goes here. You can use an alternate
|
14
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
15
|
+
# assertions if you prefer.
|
16
|
+
config.expect_with :rspec do |expectations|
|
17
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
18
|
+
# and `failure_message` of custom matchers include text for helper methods
|
19
|
+
# defined using `chain`, e.g.:
|
20
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
21
|
+
# # => "be bigger than 2 and smaller than 4"
|
22
|
+
# ...rather than:
|
23
|
+
# # => "be bigger than 2"
|
24
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
25
|
+
end
|
26
|
+
|
27
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
28
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
29
|
+
config.mock_with :rspec do |mocks|
|
30
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
31
|
+
# a real object. This is generally recommended, and will default to
|
32
|
+
# `true` in RSpec 4.
|
33
|
+
mocks.verify_partial_doubles = true
|
34
|
+
end
|
35
|
+
|
36
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
37
|
+
# have no way to turn it off -- the option exists only for backwards
|
38
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
39
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
40
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
41
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
42
|
+
|
43
|
+
# The settings below are suggested to provide a good initial experience
|
44
|
+
# with RSpec, but feel free to customize to your heart's content.
|
45
|
+
|
46
|
+
# This allows you to limit a spec run to individual examples or groups
|
47
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
48
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
49
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
50
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
51
|
+
config.filter_run_when_matching :focus
|
52
|
+
|
53
|
+
# Allows RSpec to persist some state between runs in order to support
|
54
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
55
|
+
# you configure your source control system to ignore this file.
|
56
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
57
|
+
|
58
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
59
|
+
# recommended. For more details, see:
|
60
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
61
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
62
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
63
|
+
# config.disable_monkey_patching!
|
64
|
+
|
65
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
66
|
+
# file, and it's useful to allow more verbose output when running an
|
67
|
+
# individual spec file.
|
68
|
+
if config.files_to_run.one?
|
69
|
+
# Use the documentation formatter for detailed output,
|
70
|
+
# unless a formatter has already been configured
|
71
|
+
# (e.g. via a command-line flag).
|
72
|
+
config.default_formatter = 'doc'
|
73
|
+
end
|
74
|
+
|
75
|
+
# Print the 10 slowest examples and example groups at the
|
76
|
+
# end of the spec run, to help surface which specs are running
|
77
|
+
# particularly slow.
|
78
|
+
config.profile_examples = 10
|
79
|
+
|
80
|
+
# Run specs in random order to surface order dependencies. If you find an
|
81
|
+
# order dependency and want to debug it, you can fix the order by providing
|
82
|
+
# the seed, which is printed after each run.
|
83
|
+
# --seed 1234
|
84
|
+
config.order = :random
|
85
|
+
|
86
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
87
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
88
|
+
# test failures related to randomization by passing the same `--seed` value
|
89
|
+
# as the one that triggered the failure.
|
90
|
+
Kernel.srand config.seed
|
91
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naomi Dushay
|
8
8
|
- Bess Sadler
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-02-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 1.6.6
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 1.6.6
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: nom-xml
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -57,16 +57,16 @@ dependencies:
|
|
57
57
|
name: edtf
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
62
|
+
version: '3.0'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
69
|
+
version: '3.0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rake
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +123,20 @@ dependencies:
|
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '3.0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: simplecov
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 0.17.0
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 0.17.0
|
126
140
|
- !ruby/object:Gem::Dependency
|
127
141
|
name: equivalent-xml
|
128
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,10 +162,9 @@ extra_rdoc_files:
|
|
148
162
|
- LICENSE
|
149
163
|
- README.md
|
150
164
|
files:
|
151
|
-
- ".
|
165
|
+
- ".github/workflows/ruby.yml"
|
152
166
|
- ".gitignore"
|
153
167
|
- ".rspec"
|
154
|
-
- ".travis.yml"
|
155
168
|
- ".yardopts"
|
156
169
|
- Gemfile
|
157
170
|
- LICENSE
|
@@ -172,26 +185,29 @@ files:
|
|
172
185
|
- lib/mods/title_info.rb
|
173
186
|
- lib/mods/version.rb
|
174
187
|
- mods.gemspec
|
175
|
-
- spec/
|
188
|
+
- spec/fixture_data/hp566jq8781.xml
|
176
189
|
- spec/fixture_data/shpc1.mods.xml
|
177
|
-
- spec/
|
178
|
-
- spec/
|
179
|
-
- spec/
|
180
|
-
- spec/
|
181
|
-
- spec/
|
182
|
-
- spec/
|
183
|
-
- spec/
|
184
|
-
- spec/
|
185
|
-
- spec/
|
186
|
-
- spec/
|
190
|
+
- spec/integration/parker_spec.rb
|
191
|
+
- spec/lib/date_spec.rb
|
192
|
+
- spec/lib/language_spec.rb
|
193
|
+
- spec/lib/location_spec.rb
|
194
|
+
- spec/lib/name_spec.rb
|
195
|
+
- spec/lib/origin_info_spec.rb
|
196
|
+
- spec/lib/part_spec.rb
|
197
|
+
- spec/lib/physical_description_spec.rb
|
198
|
+
- spec/lib/reader_spec.rb
|
199
|
+
- spec/lib/record_info_spec.rb
|
200
|
+
- spec/lib/record_spec.rb
|
201
|
+
- spec/lib/related_item_spec.rb
|
202
|
+
- spec/lib/subject_spec.rb
|
203
|
+
- spec/lib/title_spec.rb
|
204
|
+
- spec/lib/top_level_elmnts_simple_spec.rb
|
187
205
|
- spec/spec_helper.rb
|
188
|
-
- spec/
|
189
|
-
- spec/title_spec.rb
|
190
|
-
- spec/top_level_elmnts_simple_spec.rb
|
206
|
+
- spec/support/fixtures.rb
|
191
207
|
homepage: https://github.com/sul-dlss/mods
|
192
208
|
licenses: []
|
193
209
|
metadata: {}
|
194
|
-
post_install_message:
|
210
|
+
post_install_message:
|
195
211
|
rdoc_options: []
|
196
212
|
require_paths:
|
197
213
|
- lib
|
@@ -206,25 +222,27 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
222
|
- !ruby/object:Gem::Version
|
207
223
|
version: '0'
|
208
224
|
requirements: []
|
209
|
-
|
210
|
-
|
211
|
-
signing_key:
|
225
|
+
rubygems_version: 3.2.32
|
226
|
+
signing_key:
|
212
227
|
specification_version: 4
|
213
228
|
summary: Parse MODS (Metadata Object Description Schema) records.
|
214
229
|
test_files:
|
215
|
-
- spec/
|
230
|
+
- spec/fixture_data/hp566jq8781.xml
|
216
231
|
- spec/fixture_data/shpc1.mods.xml
|
217
|
-
- spec/
|
218
|
-
- spec/
|
219
|
-
- spec/
|
220
|
-
- spec/
|
221
|
-
- spec/
|
222
|
-
- spec/
|
223
|
-
- spec/
|
224
|
-
- spec/
|
225
|
-
- spec/
|
226
|
-
- spec/
|
232
|
+
- spec/integration/parker_spec.rb
|
233
|
+
- spec/lib/date_spec.rb
|
234
|
+
- spec/lib/language_spec.rb
|
235
|
+
- spec/lib/location_spec.rb
|
236
|
+
- spec/lib/name_spec.rb
|
237
|
+
- spec/lib/origin_info_spec.rb
|
238
|
+
- spec/lib/part_spec.rb
|
239
|
+
- spec/lib/physical_description_spec.rb
|
240
|
+
- spec/lib/reader_spec.rb
|
241
|
+
- spec/lib/record_info_spec.rb
|
242
|
+
- spec/lib/record_spec.rb
|
243
|
+
- spec/lib/related_item_spec.rb
|
244
|
+
- spec/lib/subject_spec.rb
|
245
|
+
- spec/lib/title_spec.rb
|
246
|
+
- spec/lib/top_level_elmnts_simple_spec.rb
|
227
247
|
- spec/spec_helper.rb
|
228
|
-
- spec/
|
229
|
-
- spec/title_spec.rb
|
230
|
-
- spec/top_level_elmnts_simple_spec.rb
|
248
|
+
- spec/support/fixtures.rb
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|
data/.travis.yml
DELETED
data/spec/language_spec.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Mods <language> Element" do
|
4
|
-
before(:all) do
|
5
|
-
@mods_rec = Mods::Record.new
|
6
|
-
end
|
7
|
-
|
8
|
-
context "basic <language> terminology pieces" do
|
9
|
-
|
10
|
-
context "namespace aware" do
|
11
|
-
before(:all) do
|
12
|
-
@ns_decl = "xmlns='#{Mods::MODS_NS}'"
|
13
|
-
@iso639_2b_code = "<mods #{@ns_decl}><language><languageTerm authority='iso639-2b' type='code'>fre</languageTerm></language></mods>"
|
14
|
-
@iso639_2b_code_ln = @mods_rec.from_str(@iso639_2b_code).language
|
15
|
-
mult_code_terms = "<mods #{@ns_decl}><language><languageTerm authority='iso639-2b' type='code'>spa</languageTerm><languageTerm authority='iso639-2b' type='code'>dut</languageTerm></language></mods>"
|
16
|
-
@mult_code_terms = @mods_rec.from_str(mult_code_terms).language
|
17
|
-
mult_text_terms = "<mods #{@ns_decl}><language><languageTerm authority='iso639-2b' type='text'>Chinese</languageTerm><languageTerm authority='iso639-2b' type='text'>Spanish</languageTerm></language></mods>"
|
18
|
-
@mult_text_terms = @mods_rec.from_str(mult_text_terms).language
|
19
|
-
@ex_array = [@iso639_2b_code_ln, @mult_code_terms, @mult_text_terms]
|
20
|
-
end
|
21
|
-
it "should be a NodeSet" do
|
22
|
-
@ex_array.each { |t| expect(t).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
23
|
-
end
|
24
|
-
it "should have as many members as there are <language> elements in the xml" do
|
25
|
-
@ex_array.each { |t| expect(t.size).to eq(1) }
|
26
|
-
end
|
27
|
-
|
28
|
-
context "<languageTerm> child element" do
|
29
|
-
it "should understand languageTerm.type_at attribute" do
|
30
|
-
expect(@iso639_2b_code_ln.languageTerm.type_at).to eq(["code"])
|
31
|
-
end
|
32
|
-
it "should understand languageTerm.authority attribute" do
|
33
|
-
expect(@iso639_2b_code_ln.languageTerm.authority).to eq(["iso639-2b"])
|
34
|
-
end
|
35
|
-
it "should understand languageTerm value" do
|
36
|
-
expect(@iso639_2b_code_ln.languageTerm.text).to eq("fre")
|
37
|
-
expect(@iso639_2b_code_ln.languageTerm.size).to eq(1)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should recognize all authority attributes" do
|
41
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
42
|
-
@mods_rec.from_str("<mods #{@ns_decl}><language><languageTerm #{a}='attr_val'>zzz</languageTerm></language></mods>")
|
43
|
-
expect(@mods_rec.language.languageTerm.send(a.to_sym)).to eq(['attr_val'])
|
44
|
-
}
|
45
|
-
end
|
46
|
-
end # <languageTerm>
|
47
|
-
|
48
|
-
it "should get one language.code_term for each languageTerm element with a type attribute of 'code'" do
|
49
|
-
expect(@iso639_2b_code_ln.code_term.size).to eq(1)
|
50
|
-
expect(@iso639_2b_code_ln.code_term.text).to eq("fre")
|
51
|
-
expect(@mult_code_terms.code_term.size).to eq(2)
|
52
|
-
expect(@mult_code_terms.code_term.first.text).to include("spa")
|
53
|
-
expect(@mult_code_terms.code_term[1].text).to eq("dut")
|
54
|
-
end
|
55
|
-
it "should get one language.text_term for each languageTerm element with a type attribute of 'text'" do
|
56
|
-
expect(@mult_text_terms.text_term.size).to eq(2)
|
57
|
-
expect(@mult_text_terms.text_term.first.text).to include("Chinese")
|
58
|
-
expect(@mult_text_terms.text_term[1].text).to eq("Spanish")
|
59
|
-
end
|
60
|
-
end # namespace_aware
|
61
|
-
|
62
|
-
|
63
|
-
context "NOT namespace aware" do
|
64
|
-
before(:all) do
|
65
|
-
@iso639_2b_code = "<mods><language><languageTerm authority='iso639-2b' type='code'>fre</languageTerm></language></mods>"
|
66
|
-
@iso639_2b_code_ln = @mods_rec.from_str(@iso639_2b_code, false).language
|
67
|
-
mult_code_terms = "<mods><language><languageTerm authority='iso639-2b' type='code'>spa</languageTerm><languageTerm authority='iso639-2b' type='code'>dut</languageTerm></language></mods>"
|
68
|
-
@mult_code_terms = @mods_rec.from_str(mult_code_terms, false).language
|
69
|
-
mult_text_terms = "<mods><language><languageTerm authority='iso639-2b' type='text'>Chinese</languageTerm><languageTerm authority='iso639-2b' type='text'>Spanish</languageTerm></language></mods>"
|
70
|
-
@mult_text_terms = @mods_rec.from_str(mult_text_terms, false).language
|
71
|
-
@ex_array = [@iso639_2b_code_ln, @mult_code_terms, @mult_text_terms]
|
72
|
-
end
|
73
|
-
it "should be a NodeSet" do
|
74
|
-
@ex_array.each { |t| expect(t).to be_an_instance_of(Nokogiri::XML::NodeSet) }
|
75
|
-
end
|
76
|
-
it "should have as many members as there are <language> elements in the xml" do
|
77
|
-
@ex_array.each { |t| expect(t.size).to eq(1) }
|
78
|
-
end
|
79
|
-
|
80
|
-
context "<languageTerm> child element" do
|
81
|
-
it "should understand languageTerm.type_at attribute" do
|
82
|
-
expect(@iso639_2b_code_ln.languageTerm.type_at).to eq(["code"])
|
83
|
-
end
|
84
|
-
it "should understand languageTerm.authority attribute" do
|
85
|
-
expect(@iso639_2b_code_ln.languageTerm.authority).to eq(["iso639-2b"])
|
86
|
-
end
|
87
|
-
it "should understand languageTerm value" do
|
88
|
-
expect(@iso639_2b_code_ln.languageTerm.text).to eq("fre")
|
89
|
-
expect(@iso639_2b_code_ln.languageTerm.size).to eq(1)
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should recognize all authority attributes" do
|
93
|
-
Mods::AUTHORITY_ATTRIBS.each { |a|
|
94
|
-
@mods_rec.from_str("<mods><language><languageTerm #{a}='attr_val'>zzz</languageTerm></language></mods>", false)
|
95
|
-
expect(@mods_rec.language.languageTerm.send(a.to_sym)).to eq(['attr_val'])
|
96
|
-
}
|
97
|
-
end
|
98
|
-
end # <languageTerm>
|
99
|
-
|
100
|
-
it "should get one language.code_term for each languageTerm element with a type attribute of 'code'" do
|
101
|
-
expect(@iso639_2b_code_ln.code_term.size).to eq(1)
|
102
|
-
expect(@iso639_2b_code_ln.code_term.text).to eq("fre")
|
103
|
-
expect(@mult_code_terms.code_term.size).to eq(2)
|
104
|
-
expect(@mult_code_terms.code_term.first.text).to include("spa")
|
105
|
-
expect(@mult_code_terms.code_term[1].text).to eq("dut")
|
106
|
-
end
|
107
|
-
it "should get one language.text_term for each languageTerm element with a type attribute of 'text'" do
|
108
|
-
expect(@mult_text_terms.text_term.size).to eq(2)
|
109
|
-
expect(@mult_text_terms.text_term.first.text).to include("Chinese")
|
110
|
-
expect(@mult_text_terms.text_term[1].text).to eq("Spanish")
|
111
|
-
end
|
112
|
-
end # NOT namespace_aware
|
113
|
-
|
114
|
-
end # basic <language> terminology pieces
|
115
|
-
|
116
|
-
# note that Mods::Record.languages tests are in record_spec
|
117
|
-
|
118
|
-
end
|