dbd 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +0 -1
- data/HISTORY.txt +9 -0
- data/README.md +47 -39
- data/bin/test_1.rb +4 -4
- data/bin/test_5.rb +4 -4
- data/docs/test.rb +11 -11
- data/lib/dbd.rb +2 -2
- data/lib/dbd/context.rb +65 -0
- data/lib/dbd/context_fact.rb +76 -0
- data/lib/dbd/errors.rb +1 -1
- data/lib/dbd/fact.rb +37 -37
- data/lib/dbd/fact/collection.rb +5 -5
- data/lib/dbd/fact/factory.rb +6 -6
- data/lib/dbd/graph.rb +2 -2
- data/lib/dbd/resource.rb +25 -24
- data/lib/dbd/version.rb +1 -1
- data/spec/lib/dbd/context/context_spec.rb +74 -0
- data/spec/lib/dbd/context_fact/methods_spec.rb +79 -0
- data/spec/lib/dbd/context_fact/new_spec.rb +51 -0
- data/spec/lib/dbd/context_fact/test_factories_spec.rb +24 -0
- data/spec/lib/dbd/errors/errors_spec.rb +30 -0
- data/spec/lib/dbd/fact/collection/collection_spec.rb +58 -58
- data/spec/lib/dbd/fact/factory/factory_spec.rb +3 -3
- data/spec/lib/dbd/fact/methods_spec.rb +12 -12
- data/spec/lib/dbd/fact/new_spec.rb +9 -9
- data/spec/lib/dbd/fact/subject/test_factories_spec.rb +4 -4
- data/spec/lib/dbd/fact/test_factories_spec.rb +18 -18
- data/spec/lib/dbd/graph/add_to_graph_spec.rb +22 -22
- data/spec/lib/dbd/graph/from_csv_spec.rb +16 -16
- data/spec/lib/dbd/graph/test_factories_spec.rb +11 -11
- data/spec/lib/dbd/graph/to_csv_spec.rb +18 -18
- data/spec/lib/dbd/performance_spec.rb +4 -4
- data/spec/lib/dbd/resource/collection_spec.rb +28 -30
- data/spec/lib/dbd/resource/new_spec.rb +10 -11
- data/spec/lib/dbd/resource/test_factories_spec.rb +8 -7
- data/spec/lib/dbd/version/version_spec.rb +9 -0
- data/spec/test_factories/context.rb +16 -0
- data/spec/test_factories/{provenance_fact.rb → context_fact.rb} +6 -6
- data/spec/test_factories/fact.rb +23 -23
- data/spec/test_factories/fact/subject.rb +1 -1
- data/spec/test_factories/graph.rb +7 -7
- data/spec/test_factories/resource.rb +15 -10
- metadata +20 -16
- data/lib/dbd/provenance_fact.rb +0 -77
- data/lib/dbd/provenance_resource.rb +0 -63
- data/spec/lib/dbd/provenance_fact/methods_spec.rb +0 -78
- data/spec/lib/dbd/provenance_fact/new_spec.rb +0 -51
- data/spec/lib/dbd/provenance_fact/test_factories_spec.rb +0 -24
- data/spec/lib/dbd/provenance_resource/provenance_resource_spec.rb +0 -75
- data/spec/test_factories/provenance_resource.rb +0 -16
@@ -0,0 +1,16 @@
|
|
1
|
+
module TestFactories
|
2
|
+
module Context
|
3
|
+
|
4
|
+
def self.factory_for
|
5
|
+
::Dbd::Context
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.context
|
9
|
+
factory_for.new.tap do |context|
|
10
|
+
context << TestFactories::ContextFact.visibility
|
11
|
+
context << TestFactories::ContextFact.created_by
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -1,32 +1,32 @@
|
|
1
1
|
# encoding=utf-8
|
2
2
|
module TestFactories
|
3
|
-
module
|
3
|
+
module ContextFact
|
4
4
|
def self.factory_for
|
5
|
-
::Dbd::
|
5
|
+
::Dbd::ContextFact
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.new_subject
|
9
9
|
factory_for.factory.new_subject
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.
|
12
|
+
def self.visibility(subject = nil)
|
13
13
|
factory_for.new(
|
14
14
|
subject: subject,
|
15
|
-
predicate: '
|
15
|
+
predicate: 'context:visibility',
|
16
16
|
object: 'public')
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.created_by(subject = nil)
|
20
20
|
factory_for.new(
|
21
21
|
subject: subject,
|
22
|
-
predicate: '
|
22
|
+
predicate: 'dcterms:creator',
|
23
23
|
object: 'peter_v')
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.original_source(subject = nil)
|
27
27
|
factory_for.new(
|
28
28
|
subject: subject,
|
29
|
-
predicate: '
|
29
|
+
predicate: 'prov:source',
|
30
30
|
object: "this has a comma , a newline \n and a double quote \"")
|
31
31
|
end
|
32
32
|
|
data/spec/test_factories/fact.rb
CHANGED
@@ -18,9 +18,9 @@ module TestFactories
|
|
18
18
|
'Gandhi']
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.fact_1(
|
21
|
+
def self.fact_1(context_subject = nil)
|
22
22
|
factory_for.new(
|
23
|
-
|
23
|
+
context_subject: context_subject,
|
24
24
|
predicate: 'http://example.org/test/name',
|
25
25
|
object: 'Gandhi')
|
26
26
|
end
|
@@ -32,9 +32,9 @@ module TestFactories
|
|
32
32
|
object: 'Gandhi')
|
33
33
|
end
|
34
34
|
|
35
|
-
def self.fact_with_special_chars(
|
35
|
+
def self.fact_with_special_chars(context_subject = nil, subject = nil)
|
36
36
|
factory_for.new(
|
37
|
-
|
37
|
+
context_subject: context_subject,
|
38
38
|
subject: subject,
|
39
39
|
predicate: 'http://example.org/test/comment',
|
40
40
|
object: "A long story with a newline\nreally with a comma, a double quote \" and a non-ASCII char éà Über.")
|
@@ -47,41 +47,41 @@ module TestFactories
|
|
47
47
|
object: 'Gandhi')
|
48
48
|
end
|
49
49
|
|
50
|
-
def self.fact_2_with_subject(
|
50
|
+
def self.fact_2_with_subject(context_subject = nil)
|
51
51
|
factory_for.new(
|
52
|
-
|
52
|
+
context_subject: context_subject,
|
53
53
|
subject: new_subject,
|
54
54
|
predicate: 'http://example.org/test/name',
|
55
55
|
object: 'Mandela')
|
56
56
|
end
|
57
57
|
|
58
|
-
def self.fact_3_with_subject(
|
58
|
+
def self.fact_3_with_subject(context_subject = nil)
|
59
59
|
factory_for.new(
|
60
|
-
|
60
|
+
context_subject: context_subject,
|
61
61
|
subject: new_subject,
|
62
62
|
predicate: 'http://example.org/test/name',
|
63
63
|
object: 'King')
|
64
64
|
end
|
65
65
|
|
66
|
-
def self.data_fact(
|
66
|
+
def self.data_fact(context_subject = nil, subject = nil)
|
67
67
|
factory_for.new(
|
68
|
-
|
68
|
+
context_subject: context_subject,
|
69
69
|
subject: subject,
|
70
70
|
predicate: 'http://example.org/test/name',
|
71
71
|
object: 'Aung San Suu Kyi')
|
72
72
|
end
|
73
73
|
|
74
|
-
def self.data_fact_EU(
|
74
|
+
def self.data_fact_EU(context_subject = nil, subject = nil)
|
75
75
|
factory_for.new(
|
76
|
-
|
76
|
+
context_subject: context_subject,
|
77
77
|
subject: subject,
|
78
78
|
predicate: 'http://example.org/test/name',
|
79
79
|
object: 'European Union')
|
80
80
|
end
|
81
81
|
|
82
|
-
def self.fact_with_newline(
|
82
|
+
def self.fact_with_newline(context_subject = nil, subject = nil)
|
83
83
|
factory_for.new(
|
84
|
-
|
84
|
+
context_subject: context_subject,
|
85
85
|
subject: subject,
|
86
86
|
predicate: 'http://example.org/test/comment',
|
87
87
|
object: "A long story\nreally.")
|
@@ -92,7 +92,7 @@ module TestFactories
|
|
92
92
|
fact_with_forced_id(fixed_id).tap do |fact|
|
93
93
|
fact.time_stamp = TestFactories::TimeStamp.fixed_time_stamp
|
94
94
|
fact.subject = TestFactories::Fact::Subject.fixed_subject
|
95
|
-
fact.
|
95
|
+
fact.context_subject = TestFactories::Fact::Subject.fixed_context_subject
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -104,18 +104,18 @@ module TestFactories
|
|
104
104
|
o
|
105
105
|
end
|
106
106
|
|
107
|
-
def self.fact_2_3(
|
107
|
+
def self.fact_2_3(context_subject)
|
108
108
|
factory_for_instance.tap do |fact_collection|
|
109
|
-
fact_collection << Fact.fact_2_with_subject(
|
110
|
-
fact_collection << Fact.fact_3_with_subject(
|
109
|
+
fact_collection << Fact.fact_2_with_subject(context_subject)
|
110
|
+
fact_collection << Fact.fact_3_with_subject(context_subject)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
-
def self.
|
115
|
-
factory_for_instance.tap do |
|
116
|
-
|
117
|
-
|
118
|
-
|
114
|
+
def self.context_facts(subject)
|
115
|
+
factory_for_instance.tap do |context_facts|
|
116
|
+
context_facts << ContextFact.visibility(subject)
|
117
|
+
context_facts << ContextFact.created_by(subject)
|
118
|
+
context_facts << ContextFact.original_source(subject)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -8,18 +8,18 @@ module TestFactories
|
|
8
8
|
::Dbd::Fact.factory.new_subject
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.
|
12
|
-
factory_for.new << TestFactories::
|
11
|
+
def self.only_context
|
12
|
+
factory_for.new << TestFactories::Context.context
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.only_facts(
|
16
|
-
factory_for.new << TestFactories::Resource.facts_resource(
|
15
|
+
def self.only_facts(context_subject = new_subject)
|
16
|
+
factory_for.new << TestFactories::Resource.facts_resource(context_subject)
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.full
|
20
|
-
|
21
|
-
resource = TestFactories::Resource.facts_resource(
|
22
|
-
factory_for.new <<
|
20
|
+
context = TestFactories::Context.context
|
21
|
+
resource = TestFactories::Resource.facts_resource(context.subject)
|
22
|
+
factory_for.new << context << resource
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -5,23 +5,28 @@ module TestFactories
|
|
5
5
|
::Dbd::Resource
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
# TODO get this from the Resource class
|
9
|
+
def self.element_class
|
10
|
+
::Dbd::Fact
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.
|
14
|
-
subject =
|
15
|
-
factory_for.new(subject: subject,
|
16
|
-
|
17
|
-
|
13
|
+
def self.empty(context_subject)
|
14
|
+
subject = element_class.factory.new_subject
|
15
|
+
factory_for.new(subject: subject, context_subject: context_subject)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.facts_resource(context_subject = context_subject())
|
19
|
+
subject = element_class.factory.new_subject
|
20
|
+
factory_for.new(subject: subject, context_subject: context_subject).tap do |resource|
|
21
|
+
resource << TestFactories::Fact.data_fact(context_subject, subject)
|
22
|
+
resource << TestFactories::Fact.data_fact_EU(context_subject, subject)
|
18
23
|
end
|
19
24
|
end
|
20
25
|
|
21
26
|
private
|
22
27
|
|
23
|
-
def self.
|
24
|
-
TestFactories::
|
28
|
+
def self.context_subject
|
29
|
+
TestFactories::ContextFact.new_subject
|
25
30
|
end
|
26
31
|
|
27
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Vandenabeele
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -181,6 +181,8 @@ files:
|
|
181
181
|
- docs/stories/013_read_graph_from_CSV.txt
|
182
182
|
- docs/test.rb
|
183
183
|
- lib/dbd.rb
|
184
|
+
- lib/dbd/context.rb
|
185
|
+
- lib/dbd/context_fact.rb
|
184
186
|
- lib/dbd/errors.rb
|
185
187
|
- lib/dbd/fact.rb
|
186
188
|
- lib/dbd/fact/collection.rb
|
@@ -190,8 +192,6 @@ files:
|
|
190
192
|
- lib/dbd/graph.rb
|
191
193
|
- lib/dbd/helpers/ordered_set_collection.rb
|
192
194
|
- lib/dbd/helpers/uuid.rb
|
193
|
-
- lib/dbd/provenance_fact.rb
|
194
|
-
- lib/dbd/provenance_resource.rb
|
195
195
|
- lib/dbd/rdf_base.rb
|
196
196
|
- lib/dbd/repo.rb
|
197
197
|
- lib/dbd/repo/neo4j_repo.rb
|
@@ -199,6 +199,11 @@ files:
|
|
199
199
|
- lib/dbd/resource.rb
|
200
200
|
- lib/dbd/time_stamp.rb
|
201
201
|
- lib/dbd/version.rb
|
202
|
+
- spec/lib/dbd/context/context_spec.rb
|
203
|
+
- spec/lib/dbd/context_fact/methods_spec.rb
|
204
|
+
- spec/lib/dbd/context_fact/new_spec.rb
|
205
|
+
- spec/lib/dbd/context_fact/test_factories_spec.rb
|
206
|
+
- spec/lib/dbd/errors/errors_spec.rb
|
202
207
|
- spec/lib/dbd/fact/collection/collection_spec.rb
|
203
208
|
- spec/lib/dbd/fact/factory/factory_spec.rb
|
204
209
|
- spec/lib/dbd/fact/id/id_spec.rb
|
@@ -215,10 +220,6 @@ files:
|
|
215
220
|
- spec/lib/dbd/helpers/ordered_set_collection/ordered_set_collection_spec.rb
|
216
221
|
- spec/lib/dbd/helpers/uuid/uuid_spec.rb
|
217
222
|
- spec/lib/dbd/performance_spec.rb
|
218
|
-
- spec/lib/dbd/provenance_fact/methods_spec.rb
|
219
|
-
- spec/lib/dbd/provenance_fact/new_spec.rb
|
220
|
-
- spec/lib/dbd/provenance_fact/test_factories_spec.rb
|
221
|
-
- spec/lib/dbd/provenance_resource/provenance_resource_spec.rb
|
222
223
|
- spec/lib/dbd/rdf_base/rdf_base_spec.rb
|
223
224
|
- spec/lib/dbd/repo/neo4j_repo/base_spec.rb
|
224
225
|
- spec/lib/dbd/repo/neo4j_repo/performance_spec.rb
|
@@ -229,13 +230,14 @@ files:
|
|
229
230
|
- spec/lib/dbd/time_stamp/methods_spec.rb
|
230
231
|
- spec/lib/dbd/time_stamp/new_spec.rb
|
231
232
|
- spec/lib/dbd/time_stamp/test_factories_spec.rb
|
233
|
+
- spec/lib/dbd/version/version_spec.rb
|
232
234
|
- spec/spec_helper.rb
|
235
|
+
- spec/test_factories/context.rb
|
236
|
+
- spec/test_factories/context_fact.rb
|
233
237
|
- spec/test_factories/fact.rb
|
234
238
|
- spec/test_factories/fact/id.rb
|
235
239
|
- spec/test_factories/fact/subject.rb
|
236
240
|
- spec/test_factories/graph.rb
|
237
|
-
- spec/test_factories/provenance_fact.rb
|
238
|
-
- spec/test_factories/provenance_resource.rb
|
239
241
|
- spec/test_factories/resource.rb
|
240
242
|
- spec/test_factories/time_stamp.rb
|
241
243
|
homepage: ''
|
@@ -263,6 +265,11 @@ signing_key:
|
|
263
265
|
specification_version: 4
|
264
266
|
summary: A data store that (almost) never forgets
|
265
267
|
test_files:
|
268
|
+
- spec/lib/dbd/context/context_spec.rb
|
269
|
+
- spec/lib/dbd/context_fact/methods_spec.rb
|
270
|
+
- spec/lib/dbd/context_fact/new_spec.rb
|
271
|
+
- spec/lib/dbd/context_fact/test_factories_spec.rb
|
272
|
+
- spec/lib/dbd/errors/errors_spec.rb
|
266
273
|
- spec/lib/dbd/fact/collection/collection_spec.rb
|
267
274
|
- spec/lib/dbd/fact/factory/factory_spec.rb
|
268
275
|
- spec/lib/dbd/fact/id/id_spec.rb
|
@@ -279,10 +286,6 @@ test_files:
|
|
279
286
|
- spec/lib/dbd/helpers/ordered_set_collection/ordered_set_collection_spec.rb
|
280
287
|
- spec/lib/dbd/helpers/uuid/uuid_spec.rb
|
281
288
|
- spec/lib/dbd/performance_spec.rb
|
282
|
-
- spec/lib/dbd/provenance_fact/methods_spec.rb
|
283
|
-
- spec/lib/dbd/provenance_fact/new_spec.rb
|
284
|
-
- spec/lib/dbd/provenance_fact/test_factories_spec.rb
|
285
|
-
- spec/lib/dbd/provenance_resource/provenance_resource_spec.rb
|
286
289
|
- spec/lib/dbd/rdf_base/rdf_base_spec.rb
|
287
290
|
- spec/lib/dbd/repo/neo4j_repo/base_spec.rb
|
288
291
|
- spec/lib/dbd/repo/neo4j_repo/performance_spec.rb
|
@@ -293,13 +296,14 @@ test_files:
|
|
293
296
|
- spec/lib/dbd/time_stamp/methods_spec.rb
|
294
297
|
- spec/lib/dbd/time_stamp/new_spec.rb
|
295
298
|
- spec/lib/dbd/time_stamp/test_factories_spec.rb
|
299
|
+
- spec/lib/dbd/version/version_spec.rb
|
296
300
|
- spec/spec_helper.rb
|
301
|
+
- spec/test_factories/context.rb
|
302
|
+
- spec/test_factories/context_fact.rb
|
297
303
|
- spec/test_factories/fact.rb
|
298
304
|
- spec/test_factories/fact/id.rb
|
299
305
|
- spec/test_factories/fact/subject.rb
|
300
306
|
- spec/test_factories/graph.rb
|
301
|
-
- spec/test_factories/provenance_fact.rb
|
302
|
-
- spec/test_factories/provenance_resource.rb
|
303
307
|
- spec/test_factories/resource.rb
|
304
308
|
- spec/test_factories/time_stamp.rb
|
305
309
|
has_rdoc:
|
data/lib/dbd/provenance_fact.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
module Dbd
|
2
|
-
|
3
|
-
##
|
4
|
-
# ProvenanceFact
|
5
|
-
#
|
6
|
-
# ProvenanceFact is derived from Fact and behaves very similar.
|
7
|
-
#
|
8
|
-
# The ProvenanceFacts with same subject form a ProvenanceResource and
|
9
|
-
# this is used as the target for the provenance_subject of a Fact.
|
10
|
-
#
|
11
|
-
# The provenance_subject of a ProvenanceFact itself is empty, so the
|
12
|
-
# usage of provenance_subject is not recursive on this level (this
|
13
|
-
# allows efficient single pass loading in an underlying database).
|
14
|
-
#
|
15
|
-
# In the serialisation of a fact stream, the presence or absence of a
|
16
|
-
# provenance_subject marks the difference between a (base) Fact and a
|
17
|
-
# ProvenanceFact.
|
18
|
-
#
|
19
|
-
# The predicates in a ProvenanceFact would typically come from a defined
|
20
|
-
# "provenance ontology". An experimental example of a provenance ontology
|
21
|
-
# is built-up on https://data.vandenabeele.com/ontologies/provenance.
|
22
|
-
class ProvenanceFact < Fact
|
23
|
-
|
24
|
-
##
|
25
|
-
# Builds a new ProvenanceFact.
|
26
|
-
#
|
27
|
-
# @param [Hash{Symbol => Object}] options
|
28
|
-
# @option options [Fact::Subject] :subject (new_subject) Optional: the subject for the ProvenanceFact
|
29
|
-
# @option options [String] :predicate Required: the subject for the ProvenanceFact
|
30
|
-
# @option options [String] :object Required: the object for the ProvenanceFact
|
31
|
-
def initialize(options)
|
32
|
-
validate_provenance_subject(options)
|
33
|
-
super
|
34
|
-
end
|
35
|
-
|
36
|
-
##
|
37
|
-
# Executes the required update in used_provenance_subjects.
|
38
|
-
#
|
39
|
-
# For a ProvenanceFact, there is no provenance_subject, so
|
40
|
-
# pointless to mark it in used_provenance_subjects hash.
|
41
|
-
def update_used_provenance_subjects(h)
|
42
|
-
# Do nothing (override the behaviour from super).
|
43
|
-
end
|
44
|
-
|
45
|
-
##
|
46
|
-
# Validates the presence or absence of provenance_subject.
|
47
|
-
#
|
48
|
-
# Here, in the derived ProvenanceFact, it must not be present.
|
49
|
-
# @param [#nil?] provenance_subject
|
50
|
-
# Return [nil, String] nil if valid, an error message if not
|
51
|
-
def provenance_subject_error(provenance_subject)
|
52
|
-
"Provenance subject should not be present in Provenance Fact" if provenance_subject
|
53
|
-
end
|
54
|
-
|
55
|
-
##
|
56
|
-
# Confirms this is a ProvenanceFact
|
57
|
-
#
|
58
|
-
# Needed for validations that depend on different behavior for
|
59
|
-
# a provenance_fact (mainly, no provenance_subject).
|
60
|
-
def provenance_fact?
|
61
|
-
true
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
##
|
67
|
-
# Validate that provenance_subject is not set here.
|
68
|
-
def validate_provenance_subject(options)
|
69
|
-
raise ProvenanceError if options[:provenance_subject]
|
70
|
-
end
|
71
|
-
|
72
|
-
def provenance_subject_short
|
73
|
-
"[ prov ]"
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module Dbd
|
2
|
-
##
|
3
|
-
# A ProvenanceResource is derived from a Resource, specifically
|
4
|
-
# for a Provenance.
|
5
|
-
#
|
6
|
-
# The main difference is that it does not have a provenance_subject.
|
7
|
-
class ProvenanceResource < Resource
|
8
|
-
|
9
|
-
##
|
10
|
-
# Build a new ProvenanceResource.
|
11
|
-
#
|
12
|
-
# The subject can be either given as an argument or a new (random)
|
13
|
-
# subject is automatically set (see Resource for details).
|
14
|
-
#
|
15
|
-
# A provenance_subject may not be given here.
|
16
|
-
# @option options [Fact::Subject] :subject (new_subject) Optional: the subject for the resource
|
17
|
-
def initialize(options = {})
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
##
|
22
|
-
# Add a ProvenanceFact (strictly only a ProvenanceFact).
|
23
|
-
#
|
24
|
-
# Side effect on subject:
|
25
|
-
# * if it has no subject, the subject is set in a duplicate provenance_fact
|
26
|
-
# * if is has the same subject as the resource, added unchanged.
|
27
|
-
# * if it has a different subject, a SubjectError is raised.
|
28
|
-
def <<(provenance_fact)
|
29
|
-
super
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
# Should not be called in ProvenanceResource subclass.
|
35
|
-
def provenance_subject
|
36
|
-
raise NoMethodError, "provenance_subject should not be called in ProvenanceResource."
|
37
|
-
end
|
38
|
-
|
39
|
-
def set_provenance_subject(options)
|
40
|
-
raise ArgumentError, "provenance_subject must not be in the options" if options[:provenance_subject]
|
41
|
-
end
|
42
|
-
|
43
|
-
# Validate that provenance_subject is not present here.
|
44
|
-
# This should never raise as the setter was blocked above.
|
45
|
-
def validate_provenance_subject
|
46
|
-
raise ProvenanceError if @provenance_subject
|
47
|
-
end
|
48
|
-
|
49
|
-
##
|
50
|
-
# Assert _only_ ProvenanceFacts here
|
51
|
-
def assert_fact_provenance_fact(fact)
|
52
|
-
raise ArgumentError, "Trying to add a non-ProvenanceFact to a ProvenanceResource." unless fact.provenance_fact?
|
53
|
-
end
|
54
|
-
|
55
|
-
##
|
56
|
-
# A noop for ProvenanceResource.
|
57
|
-
# @param [ProvenanceFact] provenance_fact
|
58
|
-
def set_fact_provenance!(provenance_fact)
|
59
|
-
# Do nothing
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|