rof 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rof/translators/jsonld_to_rof/accumulator.rb +17 -3
- data/lib/rof/version.rb +1 -1
- data/spec/fixtures/DLTP-999/pr76f190f54.jsonld +1 -0
- data/spec/lib/rof/translators/jsonld_to_rof/accumulator_spec.rb +34 -0
- data/spec/lib/rof/translators/jsonld_to_rof_spec.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a758b08f2917578d0af74b15925348e59f4f1be8
|
4
|
+
data.tar.gz: 66fc12edffcf6716c188186efaae4b6a27c8d7ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f42308bf063ae22ec22ddbdc19d06bddb56c741e158834e4a4e7b3f82e49389f455c629e57d7a28014ba1617d0e707883ec8086dc7f518cfdb3f027ad3013eed
|
7
|
+
data.tar.gz: 30d352eaf0860643ebe35ef40a45721dccee826dedad9c6c8a5de01e240eab48404d63d24330692523dfd72845f72fe3056d7a65766ed67b2a6455530a975f7e
|
@@ -22,15 +22,16 @@ module ROF
|
|
22
22
|
# @return [Hash]
|
23
23
|
def to_rof
|
24
24
|
rof = @rof.deep_dup
|
25
|
-
expand_blank_node_locations(rof)
|
26
|
-
append_properties_to(rof)
|
25
|
+
expand_blank_node_locations!(rof)
|
26
|
+
rof = append_properties_to(rof)
|
27
|
+
rof = force_cardinality_for_backwards_compatability(rof)
|
27
28
|
rof
|
28
29
|
end
|
29
30
|
|
30
31
|
private
|
31
32
|
|
32
33
|
# The antics of the blank node! See the specs for blank nodes to see the expected behavior.
|
33
|
-
def expand_blank_node_locations(rof)
|
34
|
+
def expand_blank_node_locations!(rof)
|
34
35
|
@blank_node_locations.each_pair do |node, locations|
|
35
36
|
locations.each_pair do |location, key_value_pairs|
|
36
37
|
data = rof
|
@@ -70,6 +71,19 @@ module ROF
|
|
70
71
|
rof
|
71
72
|
end
|
72
73
|
|
74
|
+
class TooManyEmbargoDatesError < RuntimeError
|
75
|
+
end
|
76
|
+
|
77
|
+
def force_cardinality_for_backwards_compatability(rof)
|
78
|
+
rights = rof.fetch('rights', {})
|
79
|
+
if rights.key?('embargo-date')
|
80
|
+
embargo_dates = Array.wrap(rights['embargo-date'])
|
81
|
+
raise TooManyEmbargoDatesError if embargo_dates.size > 1
|
82
|
+
rof['rights']['embargo-date'] = embargo_dates.first
|
83
|
+
end
|
84
|
+
rof
|
85
|
+
end
|
86
|
+
|
73
87
|
public
|
74
88
|
|
75
89
|
# @api public
|
data/lib/rof/version.rb
CHANGED
@@ -115,6 +115,40 @@ module ROF
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
118
|
+
|
119
|
+
describe '#to_rof' do
|
120
|
+
let(:initial_rof) do
|
121
|
+
{
|
122
|
+
"rights"=> {
|
123
|
+
"edit"=>["curate_batch_user"],
|
124
|
+
"embargo-date"=>["2016-11-16"],
|
125
|
+
"read"=>["wma1"],
|
126
|
+
"read-groups"=>["public"]
|
127
|
+
}
|
128
|
+
}
|
129
|
+
end
|
130
|
+
context 'with one embargo-date' do
|
131
|
+
it 'will have a single embargo date' do
|
132
|
+
rof = initial_rof
|
133
|
+
rof['rights']['embargo-date'] = ['2016-1-2']
|
134
|
+
expect(described_class.new(rof).to_rof['rights'].fetch('embargo-date')).to eq('2016-1-2')
|
135
|
+
end
|
136
|
+
end
|
137
|
+
context 'with more than one embargo-date' do
|
138
|
+
it 'will raise an exception' do
|
139
|
+
rof = initial_rof
|
140
|
+
rof['rights']['embargo-date'] = ['2016-1-2', '2016-2-3']
|
141
|
+
expect { described_class.new(rof).to_rof }.to raise_error(described_class::TooManyEmbargoDatesError)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
context 'no embargo-date' do
|
145
|
+
it 'will not have an embargo-date' do
|
146
|
+
rof = initial_rof
|
147
|
+
rof['rights'].delete('embargo-date')
|
148
|
+
expect { described_class.new(rof).to_rof['rights'].fetch('embargo-date') }.to raise_error(KeyError)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
118
152
|
end
|
119
153
|
end
|
120
154
|
end
|
@@ -14,6 +14,7 @@ module ROF
|
|
14
14
|
output = described_class.call(jsonld_from_curatend, {})
|
15
15
|
expect(output.size).to eq(1) # We have one item
|
16
16
|
expect(output.first.fetch('pid')).to eq('und:pr76f190f54')
|
17
|
+
expect(output.first['rights'].fetch('embargo-date')).to eq("2016-11-16")
|
17
18
|
end
|
18
19
|
end
|
19
20
|
describe '.call' do
|