dbd 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +1 -0
- data/HISTORY.txt +6 -0
- data/README.md +48 -44
- data/docs/stories/012_provenance_fact_properties_from_provenance_ontology.txt +2 -2
- data/docs/test.rb +26 -13
- data/lib/dbd/fact.rb +15 -0
- data/lib/dbd/provenance_fact.rb +4 -0
- data/lib/dbd/version.rb +1 -1
- data/spec/factories/fact.rb +8 -0
- data/spec/factories/provenance_fact.rb +8 -1
- data/spec/lib/dbd/fact_spec.rb +14 -1
- data/spec/lib/dbd/provenance_fact_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ca38e9fee78b3e02ca2a44da8dbef3e97a85df7
|
4
|
+
data.tar.gz: c55cee49db550fd26638ed9663e5e5efd3375351
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14542a1f13ab977fed503fbc3ca4b96b3c67c75262399aea0eb38d18e763d35273f8cd2ed21f6973076fc8304d8444b83454778aa5987eaa00a8dfbfd822001d
|
7
|
+
data.tar.gz: 5576b4725d7829b107aee1b025df605e847144938227373bb437d52c2f8e3325ea5d7023f6831bdef6afc4769a0e7d849b09472963c6de36e0f73ea4a798e1ac
|
data/Guardfile
CHANGED
data/HISTORY.txt
CHANGED
@@ -11,3 +11,9 @@
|
|
11
11
|
* Adding a (Provenance)Resource directly to a Graph with <<
|
12
12
|
* Simplification and cleaner implementations
|
13
13
|
* Adding Fact to a Resource now sets (provenance_)subject
|
14
|
+
|
15
|
+
0.0.3 (26 May 2013)
|
16
|
+
=====
|
17
|
+
|
18
|
+
* relax performance spec (on JRuby on Travis can be a bit slower)
|
19
|
+
* add (Provenance)Fact#short for easer viewing of fact stream
|
data/README.md
CHANGED
@@ -46,50 +46,54 @@ Open Source [MIT]
|
|
46
46
|
|
47
47
|
## Examples
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
that is a "
|
49
|
+
```
|
50
|
+
require 'dbd'
|
51
|
+
|
52
|
+
provenance = Dbd::ProvenanceResource.new
|
53
|
+
|
54
|
+
# PREFIX prov: <https://data.vandenabeele.com/ontologies/provenance#>
|
55
|
+
# PREFIX dcterms: <http://purl.org/dc/terms/>
|
56
|
+
fact_context_public = Dbd::ProvenanceFact.new(predicate: "prov:context", object: "public")
|
57
|
+
fact_source_dbd = Dbd::ProvenanceFact.new(predicate: "prov:source", object: "http://github.com/petervandenabeele/dbd")
|
58
|
+
fact_creator_peter_v = Dbd::ProvenanceFact.new(predicate: "dcterms:creator", object: "@peter_v")
|
59
|
+
fact_created_now = Dbd::ProvenanceFact.new(predicate: "dcterms:created", object: Time.now.utc)
|
60
|
+
provenance << fact_context_public
|
61
|
+
provenance << fact_source_dbd
|
62
|
+
provenance << fact_creator_peter_v
|
63
|
+
provenance << fact_created_now
|
64
|
+
|
65
|
+
nobel_peace_2012 = Dbd::Resource.new(provenance_subject: provenance.subject)
|
66
|
+
|
67
|
+
# PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
68
|
+
# PREFIX base: <https://data.vandenabeele.com/ontologies/base#>
|
69
|
+
fact_nobel_peace_2012 = Dbd::Fact.new(predicate: "base:nobelPeacePriceWinner", object: "2012")
|
70
|
+
fact_EU_label = Dbd::Fact.new(predicate: "rdfs:label", object: "EU") # this will use some RDF predicates in future
|
71
|
+
fact_EU_comment = Dbd::Fact.new(predicate: "rdfs:comment", object: "European Union")
|
72
|
+
fact_EU_story = Dbd::Fact.new(predicate: "base:story", object: "A long period of peace,\n that is a \"bliss\".")
|
73
|
+
nobel_peace_2012 << fact_nobel_peace_2012
|
74
|
+
nobel_peace_2012 << fact_EU_label
|
75
|
+
nobel_peace_2012 << fact_EU_comment
|
76
|
+
nobel_peace_2012 << fact_EU_story
|
77
|
+
|
78
|
+
graph = Dbd::Graph.new
|
79
|
+
|
80
|
+
graph << provenance
|
81
|
+
graph << nobel_peace_2012
|
82
|
+
|
83
|
+
puts "facts in short representation:"
|
84
|
+
puts graph.map(&:short)
|
85
|
+
# [ prov ] : bbc2248e : prov:context : public
|
86
|
+
# [ prov ] : bbc2248e : prov:source : http://github.com/petervandenabeele/dbd
|
87
|
+
# [ prov ] : bbc2248e : dcterms:creator : @peter_v
|
88
|
+
# [ prov ] : bbc2248e : dcterms:created : 2013-05-26 22:01:50 UTC
|
89
|
+
# bbc2248e : 78edb900 : base:nobelPeacePriceWinn : 2012
|
90
|
+
# bbc2248e : 78edb900 : rdfs:label : EU
|
91
|
+
# bbc2248e : 78edb900 : rdfs:comment : European Union
|
92
|
+
# bbc2248e : 78edb900 : base:story : A long period of peace,_ that is a "bliss".
|
93
|
+
|
94
|
+
puts "facts in full detail in CSV:"
|
95
|
+
puts graph.to_CSV
|
96
|
+
```
|
93
97
|
|
94
98
|
[RDF]: http://www.w3.org/RDF/
|
95
99
|
[Rationale]: http://github.com/petervandenabeele/dbd/blob/master/docs/rationale.md
|
@@ -3,8 +3,8 @@
|
|
3
3
|
As a client
|
4
4
|
I can read the predicates for a provenance_fact from provenance ontology
|
5
5
|
|
6
|
-
* make an ontology in a separate gem
|
6
|
+
* make an ontology in a separate gem (dbd_onto)
|
7
7
|
* import that gem
|
8
8
|
* use this ontology to build a validated Provenance Resource
|
9
|
-
* use this validate Provenance Resource instance to better
|
9
|
+
* use this validate Provenance Resource instance to better build
|
10
10
|
a ProvenanceResource
|
data/docs/test.rb
CHANGED
@@ -2,14 +2,16 @@ require 'dbd'
|
|
2
2
|
|
3
3
|
provenance = Dbd::ProvenanceResource.new
|
4
4
|
|
5
|
-
# PREFIX
|
5
|
+
# PREFIX prov: <https://data.vandenabeele.com/ontologies/provenance#>
|
6
6
|
# PREFIX dcterms: <http://purl.org/dc/terms/>
|
7
|
-
fact_context_public
|
7
|
+
fact_context_public = Dbd::ProvenanceFact.new(predicate: "prov:context", object: "public")
|
8
|
+
fact_source_dbd = Dbd::ProvenanceFact.new(predicate: "prov:source", object: "http://github.com/petervandenabeele/dbd")
|
8
9
|
fact_creator_peter_v = Dbd::ProvenanceFact.new(predicate: "dcterms:creator", object: "@peter_v")
|
9
|
-
|
10
|
+
fact_created_now = Dbd::ProvenanceFact.new(predicate: "dcterms:created", object: Time.now.utc)
|
10
11
|
provenance << fact_context_public
|
12
|
+
provenance << fact_source_dbd
|
11
13
|
provenance << fact_creator_peter_v
|
12
|
-
provenance <<
|
14
|
+
provenance << fact_created_now
|
13
15
|
|
14
16
|
nobel_peace_2012 = Dbd::Resource.new(provenance_subject: provenance.subject)
|
15
17
|
|
@@ -29,14 +31,25 @@ graph = Dbd::Graph.new
|
|
29
31
|
graph << provenance
|
30
32
|
graph << nobel_peace_2012
|
31
33
|
|
34
|
+
puts "facts in short representation:"
|
35
|
+
puts graph.map(&:short)
|
36
|
+
# [ prov ] : bbc2248e : prov:context : public
|
37
|
+
# [ prov ] : bbc2248e : prov:source : http://github.com/petervandenabeele/dbd
|
38
|
+
# [ prov ] : bbc2248e : dcterms:creator : @peter_v
|
39
|
+
# [ prov ] : bbc2248e : dcterms:created : 2013-05-26 22:01:50 UTC
|
40
|
+
# bbc2248e : 78edb900 : base:nobelPeacePriceWinn : 2012
|
41
|
+
# bbc2248e : 78edb900 : rdfs:label : EU
|
42
|
+
# bbc2248e : 78edb900 : rdfs:comment : European Union
|
43
|
+
# bbc2248e : 78edb900 : base:story : A long period of peace,_ that is a "bliss".
|
44
|
+
|
45
|
+
puts "facts in full detail in CSV:"
|
32
46
|
puts graph.to_CSV
|
33
|
-
|
34
|
-
# "
|
35
|
-
# "
|
36
|
-
# "
|
37
|
-
# "
|
38
|
-
# "
|
39
|
-
# "
|
40
|
-
# "
|
47
|
+
# "4c825f73-eda9-4b7f-a925-352f079857fb","2013-05-26 22:01:50.446202656 UTC","","bbc2248e-89f0-4480-853d-1dba51f1801d","prov:context","public"
|
48
|
+
# "09fc0e21-4749-44ab-858b-254dc24ee5a4","2013-05-26 22:01:50.446241720 UTC","","bbc2248e-89f0-4480-853d-1dba51f1801d","prov:source","http://github.com/petervandenabeele/dbd"
|
49
|
+
# "8db7f62a-d94b-43b1-b3de-827fd0e8b324","2013-05-26 22:01:50.446259428 UTC","","bbc2248e-89f0-4480-853d-1dba51f1801d","dcterms:creator","@peter_v"
|
50
|
+
# "0a76e215-cca5-44c7-9f58-f093e3ef0da7","2013-05-26 22:01:50.446272919 UTC","","bbc2248e-89f0-4480-853d-1dba51f1801d","dcterms:created","2013-05-26 22:01:50 UTC"
|
51
|
+
# "fe7c7b67-5344-4e64-a690-49c5e054b862","2013-05-26 22:01:50.446288352 UTC","bbc2248e-89f0-4480-853d-1dba51f1801d","78edb900-0ab7-4dc3-9e00-272de6d47c03","base:nobelPeacePriceWinner","2012"
|
52
|
+
# "f22bc359-e2e1-4ef1-bd8a-7f6b01d1b703","2013-05-26 22:01:50.446307209 UTC","bbc2248e-89f0-4480-853d-1dba51f1801d","78edb900-0ab7-4dc3-9e00-272de6d47c03","rdfs:label","EU"
|
53
|
+
# "7ddc9674-fcff-40bf-9fc9-d5ccdf80cfad","2013-05-26 22:01:50.446321315 UTC","bbc2248e-89f0-4480-853d-1dba51f1801d","78edb900-0ab7-4dc3-9e00-272de6d47c03","rdfs:comment","European Union"
|
54
|
+
# "dc664aee-44cd-4fc8-a6f0-fdcf4242e9c5","2013-05-26 22:01:50.446333480 UTC","bbc2248e-89f0-4480-853d-1dba51f1801d","78edb900-0ab7-4dc3-9e00-272de6d47c03","base:story","A long period of peace,
|
41
55
|
# that is a ""bliss""."
|
42
|
-
|
data/lib/dbd/fact.rb
CHANGED
@@ -139,6 +139,15 @@ module Dbd
|
|
139
139
|
self.class.attributes.map{ |attribute| self.send(attribute) }
|
140
140
|
end
|
141
141
|
|
142
|
+
##
|
143
|
+
# @return [String] a short string representation of a Fact
|
144
|
+
def short
|
145
|
+
"#{provenance_subject_short} : " \
|
146
|
+
"#{subject.to_s[0...8]} : " \
|
147
|
+
"#{predicate.to_s.ljust(24, ' ')[0...24]} : " \
|
148
|
+
"#{object.to_s[0..60].gsub(/\n/, '_')}"
|
149
|
+
end
|
150
|
+
|
142
151
|
##
|
143
152
|
# Executes the required update in used_provenance_subjects.
|
144
153
|
#
|
@@ -181,5 +190,11 @@ module Dbd
|
|
181
190
|
"Provenance subject is missing" unless provenance_subject
|
182
191
|
end
|
183
192
|
|
193
|
+
private
|
194
|
+
|
195
|
+
def provenance_subject_short
|
196
|
+
"#{provenance_subject.to_s[0...8]}"
|
197
|
+
end
|
198
|
+
|
184
199
|
end
|
185
200
|
end
|
data/lib/dbd/provenance_fact.rb
CHANGED
data/lib/dbd/version.rb
CHANGED
data/spec/factories/fact.rb
CHANGED
@@ -48,6 +48,14 @@ module Factories
|
|
48
48
|
object: "European Union")
|
49
49
|
end
|
50
50
|
|
51
|
+
def self.fact_with_newline(provenance_subject = nil, subject = nil)
|
52
|
+
factory_for.new(
|
53
|
+
provenance_subject: provenance_subject,
|
54
|
+
subject: subject,
|
55
|
+
predicate: "http://example.org/test/comment",
|
56
|
+
object: "A long story\nreally.")
|
57
|
+
end
|
58
|
+
|
51
59
|
module Collection
|
52
60
|
|
53
61
|
def self.factory_for_instance
|
@@ -20,7 +20,7 @@ module Factories
|
|
20
20
|
factory_for.new(
|
21
21
|
subject: subject,
|
22
22
|
predicate: "https://data.vandenabeele.com/ontologies/provenance#created_by",
|
23
|
-
object:"peter_v")
|
23
|
+
object: "peter_v")
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.original_source(subject = nil)
|
@@ -30,5 +30,12 @@ module Factories
|
|
30
30
|
object: "this has a comma , a newline \n and a double quote \"")
|
31
31
|
end
|
32
32
|
|
33
|
+
def self.created(subject = nil)
|
34
|
+
factory_for.new(
|
35
|
+
subject: subject,
|
36
|
+
predicate: "dcterms:created",
|
37
|
+
object: Time.now.utc)
|
38
|
+
end
|
39
|
+
|
33
40
|
end
|
34
41
|
end
|
data/spec/lib/dbd/fact_spec.rb
CHANGED
@@ -11,6 +11,7 @@ module Dbd
|
|
11
11
|
let(:subject_class) { Fact::Subject }
|
12
12
|
let(:fact_1) { Factories::Fact.fact_1(provenance_subject) }
|
13
13
|
let(:fact_2_with_subject) { Factories::Fact.fact_2_with_subject(provenance_subject) }
|
14
|
+
let(:fact_with_newline) { Factories::Fact.fact_with_newline(provenance_subject) }
|
14
15
|
|
15
16
|
describe ".new_subject" do
|
16
17
|
it "creates a new (random) subject" do
|
@@ -59,7 +60,6 @@ module Dbd
|
|
59
60
|
end
|
60
61
|
|
61
62
|
describe "time_stamp=" do
|
62
|
-
|
63
63
|
it "checks the type (too easy to try to give a Time arg" do
|
64
64
|
lambda { fact_1.time_stamp = Time.now } . should raise_error(ArgumentError)
|
65
65
|
end
|
@@ -82,6 +82,19 @@ module Dbd
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
describe "short" do
|
86
|
+
it "for a base fact shows provenance, subj, predicate, object" do
|
87
|
+
fact_1.subject = subject
|
88
|
+
fact_1.time_stamp = TimeStamp.new
|
89
|
+
fact_1.short.should match(/^[0-9a-f]{8} : [0-9a-f]{8} : http:\/\/example\.org\/test\/ : Gandhi$/)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "for a fact with a newline replaces it with a underscore" do
|
93
|
+
fact_with_newline.subject = subject
|
94
|
+
fact_with_newline.short.should match(/^[0-9a-f]{8} : [0-9a-f]{8} : http:\/\/example\.org\/test\/ : A long story_really.$/)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
85
98
|
describe "errors" do
|
86
99
|
it "the factory has no errors" do
|
87
100
|
fact_2_with_subject.errors.should be_empty
|
@@ -14,6 +14,10 @@ module Dbd
|
|
14
14
|
Factories::ProvenanceFact.created_by(subject)
|
15
15
|
end
|
16
16
|
|
17
|
+
let(:provenance_fact_created) do
|
18
|
+
Factories::ProvenanceFact.created(subject)
|
19
|
+
end
|
20
|
+
|
17
21
|
describe "#new" do
|
18
22
|
it "has a unique id (new_id.class)" do
|
19
23
|
provenance_fact_1.id.should be_a(id_class)
|
@@ -48,6 +52,16 @@ module Dbd
|
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
55
|
+
describe "short" do
|
56
|
+
it "for a provenance fact shows [ prov ], subj, predicate, object" do
|
57
|
+
provenance_fact_1.short.should match(/^\[ prov \] : [0-9a-f]{8} : https:\/\/data\.vandenabeel : public$/)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "for a provenance fact with non string object also works" do
|
61
|
+
provenance_fact_created.short.should match(/^\[ prov \] : [0-9a-f]{8} : dcterms:created : \d{4}/)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
51
65
|
describe "errors" do
|
52
66
|
|
53
67
|
it "the factory has no errors" do
|
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.3
|
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-05-
|
11
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|