rof 1.2.7 → 1.2.8
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/lib/rof/translators/jsonld_to_rof.rb +12 -9
- data/lib/rof/translators/jsonld_to_rof/accumulator.rb +24 -38
- data/lib/rof/translators/jsonld_to_rof/predicate_handler.rb +12 -2
- data/lib/rof/translators/jsonld_to_rof/predicate_object_handler.rb +4 -0
- data/lib/rof/translators/jsonld_to_rof/statement_handler.rb +2 -0
- data/lib/rof/version.rb +1 -1
- data/spec/fixtures/DLTP-1007/remediated-z029p269r94.jsonld +1 -0
- data/spec/fixtures/DLTP-1015/dltp1015.jsonld +62 -0
- data/spec/lib/rof/translators/jsonld_to_rof/accumulator_spec.rb +23 -74
- data/spec/lib/rof/translators/jsonld_to_rof/predicate_handler_spec.rb +4 -1
- data/spec/lib/rof/translators/jsonld_to_rof_spec.rb +13 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 273923b81f29ea92d235344c8049639158b81659
|
4
|
+
data.tar.gz: 94ddc93adfa0d5f48cf1813c5a36a8d91aaf9643
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 672c4233841ea90d6aed64756c5ce636f39cd8588ef8ee14d3b1ac53c6d300cd576263f80052ac66f54c67bf20b861bb455e12997c57d44557296dd389ba5d2d
|
7
|
+
data.tar.gz: 130fe821768bccd49307ff9a8ede1b8f078cbdd9247add97448c2f354e539a5eb64e95b8adbda09bcb49ec3d35e923d14d533b664af7d5474870f68f8b5a6396
|
@@ -8,7 +8,7 @@ module ROF
|
|
8
8
|
module Translators
|
9
9
|
# @api public
|
10
10
|
#
|
11
|
-
# Responsible for converting JSON LD into an ROF Hash via registered URI maps
|
11
|
+
# Responsible for converting JSON LD into an ROF Hash via registered URI maps via the `.call` method
|
12
12
|
#
|
13
13
|
# @note Some predicates require explicit mapping where as others have an assumed mapping. At present all URLs for @context of JSON-LD documents must be registered.
|
14
14
|
#
|
@@ -34,20 +34,23 @@ module ROF
|
|
34
34
|
end
|
35
35
|
|
36
36
|
PredicateHandler.register('https://library.nd.edu/ns/terms/') do |handler|
|
37
|
-
handler.
|
38
|
-
handler.
|
39
|
-
handler.map('
|
40
|
-
handler.map('
|
41
|
-
handler.map('
|
42
|
-
handler.map('
|
43
|
-
handler.map('
|
37
|
+
handler.namespace_prefix('nd:')
|
38
|
+
handler.within(['metadata'])
|
39
|
+
handler.map('accessEdit', to: ['rights', 'edit'], force: true)
|
40
|
+
handler.map('accessRead', to: ['rights', 'read'], force: true)
|
41
|
+
handler.map('accessEditGroup', to: ['rights', 'edit-groups'], force: true)
|
42
|
+
handler.map('accessReadGroup', to: ['rights', 'read-groups'], force: true)
|
43
|
+
handler.map('accessEmbargoDate', to: ['rights', 'embargo-date'], multiple: false, force: true)
|
44
|
+
handler.map('afmodel', to: ["af-model"], force: true)
|
45
|
+
handler.map('alephIdentifier', to: ['alephIdentifier'], multiple: false)
|
46
|
+
handler.map('bendoitem', to: ["bendo-item"], multiple: false, force: true)
|
44
47
|
handler.map('depositor') do |object, accumulator|
|
45
48
|
accumulator.register_properties('depositor', object)
|
46
49
|
end
|
47
50
|
handler.map('owner') do |object, accumulator|
|
48
51
|
accumulator.register_properties('owner', object)
|
49
52
|
end
|
50
|
-
handler.map('representativeFile') do |object, accumulator|
|
53
|
+
handler.map('representativeFile', multiple: false) do |object, accumulator|
|
51
54
|
accumulator.register_properties('representative', object)
|
52
55
|
end
|
53
56
|
end
|
@@ -24,7 +24,6 @@ module ROF
|
|
24
24
|
rof = @rof.deep_dup
|
25
25
|
expand_blank_node_locations!(rof)
|
26
26
|
rof = append_properties_to(rof)
|
27
|
-
rof = force_cardinality_for_backwards_compatability(rof)
|
28
27
|
rof
|
29
28
|
end
|
30
29
|
|
@@ -72,36 +71,11 @@ module ROF
|
|
72
71
|
end
|
73
72
|
|
74
73
|
class TooManyElementsError < RuntimeError
|
75
|
-
def initialize(context
|
76
|
-
super(%(
|
74
|
+
def initialize(context)
|
75
|
+
super(%(Attempted to set more than one value for #{context}))
|
77
76
|
end
|
78
77
|
end
|
79
78
|
|
80
|
-
def force_cardinality_for_backwards_compatability(rof)
|
81
|
-
rof = force_rights_cardinality(rof)
|
82
|
-
rof = force_bendo_cardinality(rof)
|
83
|
-
rof
|
84
|
-
end
|
85
|
-
|
86
|
-
def force_rights_cardinality(rof)
|
87
|
-
rights = rof.fetch('rights', {})
|
88
|
-
if rights.key?('embargo-date')
|
89
|
-
embargo_dates = Array.wrap(rights['embargo-date'])
|
90
|
-
raise TooManyElementsError.new('rights > embargo-date', 1, embargo_dates.size) if embargo_dates.size > 1
|
91
|
-
rof['rights']['embargo-date'] = embargo_dates.first
|
92
|
-
end
|
93
|
-
rof
|
94
|
-
end
|
95
|
-
|
96
|
-
def force_bendo_cardinality(rof)
|
97
|
-
if rof.key?('bendo-item')
|
98
|
-
bendo_items = Array.wrap(rof['bendo-item'])
|
99
|
-
raise TooManyElementsError.new('bendo-item', 1, bendo_items.size) if bendo_items.size > 1
|
100
|
-
rof['bendo-item'] = bendo_items.first
|
101
|
-
end
|
102
|
-
rof
|
103
|
-
end
|
104
|
-
|
105
79
|
public
|
106
80
|
|
107
81
|
# @api public
|
@@ -155,42 +129,54 @@ module ROF
|
|
155
129
|
# @api public
|
156
130
|
# @param [Array<String>, String] location - a list of nested hash keys (or a single string)
|
157
131
|
# @param [String] value - a translated value for the original RDF Statement
|
158
|
-
# @param [
|
132
|
+
# @param [Hash] options
|
133
|
+
# @option options [false, RDF::Node] blank_node
|
134
|
+
# @option options [Boolean] multiple (default true) - if true will append values to an Array; if false will have a singular (non-Array) value
|
159
135
|
# @return [Array] location, value
|
160
|
-
def add_predicate_location_and_value(location, value,
|
136
|
+
def add_predicate_location_and_value(location, value, options = {})
|
137
|
+
blank_node = options.fetch(:blank_node, false)
|
138
|
+
multiple = options.fetch(:multiple, true)
|
161
139
|
# Because I am making transformation on the location via #shift method, I need a duplication.
|
162
140
|
location = Array.wrap(location)
|
163
141
|
if location == ['pid']
|
164
142
|
return add_pid(value)
|
165
143
|
end
|
166
144
|
if blank_node
|
167
|
-
add_predicate_location_and_value_direct_for_blank_node(location, value, blank_node)
|
145
|
+
add_predicate_location_and_value_direct_for_blank_node(location, value, blank_node, multiple)
|
168
146
|
else
|
169
|
-
add_predicate_location_and_value_direct_for_non_blank_node(location, value)
|
147
|
+
add_predicate_location_and_value_direct_for_non_blank_node(location, value, multiple)
|
170
148
|
end
|
171
149
|
[location, value]
|
172
150
|
end
|
173
151
|
|
174
|
-
|
152
|
+
private
|
153
|
+
|
154
|
+
def add_predicate_location_and_value_direct_for_blank_node(location, value, blank_node, multiple)
|
175
155
|
fetch_blank_node(blank_node) # Ensure the node exists
|
176
156
|
@blank_node_locations[blank_node] ||= {}
|
177
157
|
@blank_node_locations[blank_node][location[0..-2]] ||= []
|
178
158
|
@blank_node_locations[blank_node][location[0..-2]] << { location[-1] => Array.wrap(coerce_object_to_string(value)) }
|
179
159
|
end
|
180
160
|
|
181
|
-
def add_predicate_location_and_value_direct_for_non_blank_node(location, value)
|
161
|
+
def add_predicate_location_and_value_direct_for_non_blank_node(location, value, multiple)
|
182
162
|
data = @rof
|
183
163
|
location[0..-2].each do |slug|
|
184
164
|
data[slug] ||= {}
|
185
165
|
data = data[slug]
|
186
166
|
end
|
187
167
|
slug = location[-1]
|
188
|
-
|
189
|
-
|
168
|
+
if multiple
|
169
|
+
data[slug] ||= []
|
170
|
+
data[slug] << coerce_object_to_string(value)
|
171
|
+
else
|
172
|
+
if data[slug].present?
|
173
|
+
raise TooManyElementsError.new(location)
|
174
|
+
else
|
175
|
+
data[slug] = coerce_object_to_string(value)
|
176
|
+
end
|
177
|
+
end
|
190
178
|
end
|
191
179
|
|
192
|
-
private
|
193
|
-
|
194
180
|
def coerce_object_to_string(object)
|
195
181
|
return object if object.nil?
|
196
182
|
if object.to_s =~ ROF::Translators::JsonldToRof::REGEXP_FOR_A_CURATE_RDF_SUBJECT
|
@@ -4,6 +4,11 @@ module ROF
|
|
4
4
|
module Translators
|
5
5
|
module JsonldToRof
|
6
6
|
# Responsible for dealing with registered predicates and how those are handled.
|
7
|
+
#
|
8
|
+
# The two primary entry points are `.call` and `.register`
|
9
|
+
#
|
10
|
+
# @see ROF::Translators::JsonldToRof::PredicateHandler.call
|
11
|
+
# @see ROF::Translators::JsonldToRof::PredicateHandler.register
|
7
12
|
module PredicateHandler
|
8
13
|
class UnhandledPredicateError < RuntimeError
|
9
14
|
def initialize(predicate, urls)
|
@@ -38,6 +43,9 @@ module ROF
|
|
38
43
|
end
|
39
44
|
|
40
45
|
# @api public
|
46
|
+
#
|
47
|
+
# Register a map of an RDF Predicate URL to it's spot in the ROF Hash.
|
48
|
+
#
|
41
49
|
# @param [String] url - The URL that we want to match against
|
42
50
|
# @yield The block to configure how we handle RDF Predicates that match the gvien URL
|
43
51
|
# @yieldparam [ROF::JsonldToRof::PredicateHandler::UrlHandler]
|
@@ -133,6 +141,7 @@ module ROF
|
|
133
141
|
# @param [Hash] options (with symbol keys)
|
134
142
|
# @option options [Boolean] :force - don't apply the within nor namespace prefix
|
135
143
|
# @option options [Array] :to - an array that will be nested Hash keys
|
144
|
+
# @option options [Boolean] :multiple (default true) - if true will append values to an Array; if false will have a singular (non-Array) value
|
136
145
|
# @yield If a block is given, call the block (and skip all other configuration)
|
137
146
|
# @yieldparam [String] object
|
138
147
|
# @see BlockSlugHandler for details concerning a mapping via a block
|
@@ -172,7 +181,7 @@ module ROF
|
|
172
181
|
def call(object, accumulator, blank_node)
|
173
182
|
to = @url_handler.within + Array.wrap(slug)
|
174
183
|
to[-1] = "#{@url_handler.namespace_prefix}#{to[-1]}"
|
175
|
-
accumulator.add_predicate_location_and_value(to, object, blank_node)
|
184
|
+
accumulator.add_predicate_location_and_value(to, object, blank_node: blank_node)
|
176
185
|
end
|
177
186
|
end
|
178
187
|
private_constant :ImplicitLocationHandler
|
@@ -203,11 +212,12 @@ module ROF
|
|
203
212
|
|
204
213
|
def call(object, accumulator, blank_node)
|
205
214
|
to = @options.fetch(:to)
|
215
|
+
multiple = @options.fetch(:multiple, true)
|
206
216
|
unless force?
|
207
217
|
to = @url_handler.within + Array.wrap(to)
|
208
218
|
to[-1] = "#{@url_handler.namespace_prefix}#{to[-1]}"
|
209
219
|
end
|
210
|
-
accumulator.add_predicate_location_and_value(to, object, blank_node)
|
220
|
+
accumulator.add_predicate_location_and_value(to, object, blank_node: blank_node, multiple: multiple)
|
211
221
|
end
|
212
222
|
|
213
223
|
def force?
|
@@ -5,6 +5,8 @@ module ROF
|
|
5
5
|
module Translators
|
6
6
|
module JsonldToRof
|
7
7
|
# We need to handle the Predicate / Object pair as one (thank you RDF blank nodes for this nuance)
|
8
|
+
#
|
9
|
+
# @see ROF::Translators::JsonldToRof::PredicateObjectHandler.call
|
8
10
|
module PredicateObjectHandler
|
9
11
|
# @api public
|
10
12
|
#
|
@@ -39,6 +41,7 @@ module ROF
|
|
39
41
|
def self.new(predicate, object, accumulator, options)
|
40
42
|
klass_for(object).new(predicate, object, accumulator, options)
|
41
43
|
end
|
44
|
+
private_class_method :new
|
42
45
|
|
43
46
|
class UnknownRdfObjectTypeError < RuntimeError
|
44
47
|
end
|
@@ -56,6 +59,7 @@ module ROF
|
|
56
59
|
raise UnknownRdfObjectTypeError, "Unable to determine object handler for #{object.inspect}"
|
57
60
|
end
|
58
61
|
end
|
62
|
+
private_class_method :klass_for
|
59
63
|
|
60
64
|
# @api private
|
61
65
|
class UriPredicateObjectHandler
|
data/lib/rof/version.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
{
|
2
|
+
"@context": {
|
3
|
+
"und": "https://curatesvrpprd.library.nd.edu/show/",
|
4
|
+
"bibo": "http://purl.org/ontology/bibo/",
|
5
|
+
"dc": "http://purl.org/dc/terms/",
|
6
|
+
"ebucore": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#",
|
7
|
+
"foaf": "http://xmlns.com/foaf/0.1/",
|
8
|
+
"mrel": "http://id.loc.gov/vocabulary/relators/",
|
9
|
+
"nd": "https://library.nd.edu/ns/terms/",
|
10
|
+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
|
11
|
+
"vracore": "http://purl.org/vra/",
|
12
|
+
"frels": "info:fedora/fedora-system:def/relations-external#",
|
13
|
+
"ms": "http://www.ndltd.org/standards/metadata/etdms/1.1/",
|
14
|
+
"pav": "http://purl.org/pav/",
|
15
|
+
"fedora-model": "info:fedora/fedora-system:def/model#",
|
16
|
+
"hydra": "http://projecthydra.org/ns/relations#",
|
17
|
+
"hasModel": {
|
18
|
+
"@id": "fedora-model:hasModel",
|
19
|
+
"@type": "@id"
|
20
|
+
},
|
21
|
+
"hasEditor": {
|
22
|
+
"@id": "hydra:hasEditor",
|
23
|
+
"@type": "@id"
|
24
|
+
},
|
25
|
+
"hasEditorGroup": {
|
26
|
+
"@id": "hydra:hasEditorGroup",
|
27
|
+
"@type": "@id"
|
28
|
+
},
|
29
|
+
"hasViewer": {
|
30
|
+
"@id": "hydra:hasViewer",
|
31
|
+
"@type": "@id"
|
32
|
+
},
|
33
|
+
"hasViewerGroup": {
|
34
|
+
"@id": "hydra:hasViewerGroup",
|
35
|
+
"@type": "@id"
|
36
|
+
},
|
37
|
+
"isPartOf": {
|
38
|
+
"@id": "frels:isPartOf",
|
39
|
+
"@type": "@id"
|
40
|
+
},
|
41
|
+
"isMemberOfCollection": {
|
42
|
+
"@id": "frels:isMemberOfCollection",
|
43
|
+
"@type": "@id"
|
44
|
+
},
|
45
|
+
"isEditorOf": {
|
46
|
+
"@id": "hydra:isEditorOf",
|
47
|
+
"@type": "@id"
|
48
|
+
},
|
49
|
+
"hasMember": {
|
50
|
+
"@id": "frels:hasMember",
|
51
|
+
"@type": "@id"
|
52
|
+
},
|
53
|
+
"previousVersion": "pav:previousVersion"
|
54
|
+
},
|
55
|
+
"@id": "und:9g54xg96r27",
|
56
|
+
"nd:alephIdentifier": "aleph123",
|
57
|
+
"nd:accessEmbargoDate": "2016-11-16",
|
58
|
+
"nd:bendoitem": "bendo123",
|
59
|
+
"nd:representativeFile": {
|
60
|
+
"@id": "und:representative123"
|
61
|
+
}
|
62
|
+
}
|
@@ -44,13 +44,26 @@ module ROF
|
|
44
44
|
expect(subject.to_rof).to eq({ "hello" => { "world" => ["value"] }, "kitchen" => ["another"] } )
|
45
45
|
end
|
46
46
|
|
47
|
+
context 'with multiple: true' do
|
48
|
+
it 'will raise an error if too many' do
|
49
|
+
subject.add_predicate_location_and_value(['hello', 'world'], "value", multiple: false)
|
50
|
+
expect do
|
51
|
+
subject.add_predicate_location_and_value(['hello', 'world'], "another", multiple: false)
|
52
|
+
end.to raise_error(described_class::TooManyElementsError)
|
53
|
+
end
|
54
|
+
it 'will not be an array (but instead a String)' do
|
55
|
+
subject.add_predicate_location_and_value(['hello', 'world'], "value", multiple: false)
|
56
|
+
expect(subject.to_rof.fetch('hello').fetch('world')).to eq('value')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
47
60
|
context 'handling blank nodes' do
|
48
61
|
context 'for the same node' do
|
49
62
|
it 'collects values for the same location' do
|
50
63
|
blank_node = RDF::Node.new('_b0')
|
51
64
|
subject.add_blank_node(RDF::Statement.new(blank_node, nil, nil))
|
52
|
-
subject.add_predicate_location_and_value(['parent', 'child'], "value", blank_node)
|
53
|
-
subject.add_predicate_location_and_value(['parent', 'child'], "another", blank_node)
|
65
|
+
subject.add_predicate_location_and_value(['parent', 'child'], "value", blank_node: blank_node)
|
66
|
+
subject.add_predicate_location_and_value(['parent', 'child'], "another", blank_node: blank_node)
|
54
67
|
expect(subject.to_rof).to eq({
|
55
68
|
"parent" => [{
|
56
69
|
"child" => ["value", "another"]
|
@@ -61,8 +74,8 @@ module ROF
|
|
61
74
|
it 'collects values for the same deep location' do
|
62
75
|
blank_node = RDF::Node.new('_b0')
|
63
76
|
subject.add_blank_node(RDF::Statement.new(blank_node, nil, nil))
|
64
|
-
subject.add_predicate_location_and_value(['parent', 'child', 'grandchild'], "value", blank_node)
|
65
|
-
subject.add_predicate_location_and_value(['parent', 'child', 'grandchild'], "another", blank_node)
|
77
|
+
subject.add_predicate_location_and_value(['parent', 'child', 'grandchild'], "value", blank_node: blank_node)
|
78
|
+
subject.add_predicate_location_and_value(['parent', 'child', 'grandchild'], "another", blank_node: blank_node)
|
66
79
|
expect(subject.to_rof).to eq({
|
67
80
|
"parent" => {
|
68
81
|
"child" => [{
|
@@ -75,8 +88,8 @@ module ROF
|
|
75
88
|
it 'collects values for the same location' do
|
76
89
|
blank_node = RDF::Node.new('_b0')
|
77
90
|
subject.add_blank_node(RDF::Statement.new(blank_node, nil, nil))
|
78
|
-
subject.add_predicate_location_and_value(['parent'], "value", blank_node)
|
79
|
-
subject.add_predicate_location_and_value(['parent'], "another", blank_node)
|
91
|
+
subject.add_predicate_location_and_value(['parent'], "value", blank_node: blank_node)
|
92
|
+
subject.add_predicate_location_and_value(['parent'], "another", blank_node: blank_node)
|
80
93
|
expect(subject.to_rof).to eq({
|
81
94
|
"parent" => ["value", "another"]
|
82
95
|
})
|
@@ -85,8 +98,8 @@ module ROF
|
|
85
98
|
it 'merges different locations' do
|
86
99
|
blank_node = RDF::Node.new('_b0')
|
87
100
|
subject.add_blank_node(RDF::Statement.new(blank_node, nil, nil))
|
88
|
-
subject.add_predicate_location_and_value(['parent', 'child_one'], "value", blank_node)
|
89
|
-
subject.add_predicate_location_and_value(['parent', 'child_two'], "another", blank_node)
|
101
|
+
subject.add_predicate_location_and_value(['parent', 'child_one'], "value", blank_node: blank_node)
|
102
|
+
subject.add_predicate_location_and_value(['parent', 'child_two'], "another", blank_node: blank_node)
|
90
103
|
expect(subject.to_rof).to eq({
|
91
104
|
"parent" => [{
|
92
105
|
"child_one" => ["value"],
|
@@ -102,8 +115,8 @@ module ROF
|
|
102
115
|
blank_node_2 = RDF::Node.new('_b1')
|
103
116
|
subject.add_blank_node(RDF::Statement.new(blank_node_1, nil, nil))
|
104
117
|
subject.add_blank_node(RDF::Statement.new(blank_node_2, nil, nil))
|
105
|
-
subject.add_predicate_location_and_value(['parent', 'child'], "value", blank_node_1)
|
106
|
-
subject.add_predicate_location_and_value(['parent', 'child'], "another", blank_node_2)
|
118
|
+
subject.add_predicate_location_and_value(['parent', 'child'], "value", blank_node: blank_node_1)
|
119
|
+
subject.add_predicate_location_and_value(['parent', 'child'], "another", blank_node: blank_node_2)
|
107
120
|
expect(subject.to_rof).to eq({
|
108
121
|
"parent" => [{
|
109
122
|
"child" => ["value"]
|
@@ -115,70 +128,6 @@ module ROF
|
|
115
128
|
end
|
116
129
|
end
|
117
130
|
end
|
118
|
-
|
119
|
-
describe '#to_rof' do
|
120
|
-
describe 'for embargo-date' do
|
121
|
-
let(:initial_rof) do
|
122
|
-
{
|
123
|
-
"rights"=> {
|
124
|
-
"edit"=>["curate_batch_user"],
|
125
|
-
"embargo-date"=>["2016-11-16"],
|
126
|
-
"read"=>["wma1"],
|
127
|
-
"read-groups"=>["public"]
|
128
|
-
}
|
129
|
-
}
|
130
|
-
end
|
131
|
-
context 'with one embargo-date' do
|
132
|
-
it 'will have a single embargo date' do
|
133
|
-
rof = initial_rof
|
134
|
-
rof['rights']['embargo-date'] = ['2016-1-2']
|
135
|
-
expect(described_class.new(rof).to_rof['rights'].fetch('embargo-date')).to eq('2016-1-2')
|
136
|
-
end
|
137
|
-
end
|
138
|
-
context 'with more than one embargo-date' do
|
139
|
-
it 'will raise an exception' do
|
140
|
-
rof = initial_rof
|
141
|
-
rof['rights']['embargo-date'] = ['2016-1-2', '2016-2-3']
|
142
|
-
expect { described_class.new(rof).to_rof }.to raise_error(described_class::TooManyElementsError)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
context 'no embargo-date' do
|
146
|
-
it 'will not have an embargo-date' do
|
147
|
-
rof = initial_rof
|
148
|
-
rof['rights'].delete('embargo-date')
|
149
|
-
expect { described_class.new(rof).to_rof['rights'].fetch('embargo-date') }.to raise_error(KeyError)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
describe 'bendo-item' do
|
154
|
-
let(:initial_rof) do
|
155
|
-
{
|
156
|
-
"bendo-item"=> ['abcd1']
|
157
|
-
}
|
158
|
-
end
|
159
|
-
context 'with one embargo-date' do
|
160
|
-
it 'will have a single embargo date' do
|
161
|
-
rof = initial_rof
|
162
|
-
rof['bendo-item'] = ['abcd1']
|
163
|
-
expect(described_class.new(rof).to_rof.fetch('bendo-item')).to eq('abcd1')
|
164
|
-
end
|
165
|
-
end
|
166
|
-
context 'with more than one embargo-date' do
|
167
|
-
it 'will raise an exception' do
|
168
|
-
rof = initial_rof
|
169
|
-
rof['bendo-item'] = ['abcd1', 'efgh1']
|
170
|
-
expect { described_class.new(rof).to_rof }.to raise_error(described_class::TooManyElementsError)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
context 'no embargo-date' do
|
174
|
-
it 'will not have an embargo-date' do
|
175
|
-
rof = initial_rof
|
176
|
-
rof.delete('bendo-item')
|
177
|
-
expect { described_class.new(rof).to_rof.fetch('bendo-item') }.to raise_error(KeyError)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
131
|
end
|
183
132
|
end
|
184
133
|
end
|
@@ -5,9 +5,11 @@ module ROF
|
|
5
5
|
module JsonldToRof
|
6
6
|
RSpec.describe PredicateHandler do
|
7
7
|
around do |spec|
|
8
|
-
# Ensuring that we preserve duplication of
|
8
|
+
# Ensuring that we preserve duplication of registry.
|
9
|
+
# We take a snap-shot of the registry, clear, do our tests, then restore the registry
|
9
10
|
previous_registry = described_class.send(:registry)
|
10
11
|
described_class.send(:clear_registry!)
|
12
|
+
|
11
13
|
described_class.register('https://library.nd.edu/ns/terms/') do |handler|
|
12
14
|
handler.map('accessRead', to: ['rights', 'read'])
|
13
15
|
end
|
@@ -26,6 +28,7 @@ module ROF
|
|
26
28
|
handler.map('something', to: ['another', 'somewhere'])
|
27
29
|
end
|
28
30
|
spec.run
|
31
|
+
|
29
32
|
described_class.send(:clear_registry!, previous_registry)
|
30
33
|
end
|
31
34
|
|
@@ -28,6 +28,19 @@ module ROF
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
describe 'DLTP-1015 regression verification' do
|
32
|
+
it 'converts bendo-item, embargo-date, representative and alephNumber to string' do
|
33
|
+
jsonld_from_curatend = JSON.load(File.read(File.join(GEM_ROOT, "spec/fixtures/DLTP-1015/dltp1015.jsonld")))
|
34
|
+
output = described_class.call(jsonld_from_curatend, {})
|
35
|
+
expect(output.size).to eq(1)
|
36
|
+
object = output.first
|
37
|
+
expect(object.fetch('properties')).to include('<representative>und:representative123</representative>')
|
38
|
+
expect(object.fetch('rights').fetch('embargo-date')).to eq("2016-11-16")
|
39
|
+
expect(object.fetch('metadata').fetch('nd:alephIdentifier')).to eq("aleph123")
|
40
|
+
expect(object.fetch('bendo-item')).to eq("bendo123")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
31
44
|
describe '::REGEXP_FOR_A_CURATE_RDF_SUBJECT' do
|
32
45
|
it 'handles data as expected' do
|
33
46
|
[
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -410,6 +410,7 @@ files:
|
|
410
410
|
- rof.gemspec
|
411
411
|
- spec/coverage_helper.rb
|
412
412
|
- spec/fixtures/DLTP-1007/remediated-z029p269r94.jsonld
|
413
|
+
- spec/fixtures/DLTP-1015/dltp1015.jsonld
|
413
414
|
- spec/fixtures/DLTP-999/pr76f190f54.jsonld
|
414
415
|
- spec/fixtures/a.json
|
415
416
|
- spec/fixtures/for_utility_load_items_from_json_file/multiple_items.json
|
@@ -499,6 +500,7 @@ summary: Raw Object Format
|
|
499
500
|
test_files:
|
500
501
|
- spec/coverage_helper.rb
|
501
502
|
- spec/fixtures/DLTP-1007/remediated-z029p269r94.jsonld
|
503
|
+
- spec/fixtures/DLTP-1015/dltp1015.jsonld
|
502
504
|
- spec/fixtures/DLTP-999/pr76f190f54.jsonld
|
503
505
|
- spec/fixtures/a.json
|
504
506
|
- spec/fixtures/for_utility_load_items_from_json_file/multiple_items.json
|